Manuscript Offprint

arXiv:2608.27142

GRAIN: Bridging Name and Narrative Shifts in Real-World Graph Reasoning through Invariance-Rewarded Agentic RL

Zike Yuan, Han Zhang, Jianzhi Yan, Le Liu, Cai Ke, Huozhi Zhou, Jian Xie, Jiran Yin, Yukun Cao, Yue Yu, Hui Wang, Ming Liu, Bing Qin

Abstract

Despite their potential in standardized graph tasks, Large Language Models (LLMs) remain brittle to real-world shifts in node identifiers and task formulation. While deterministic graph tools are invariant to such shifts, extracting topological structures from noisy text is highly fragile for LLMs, which often overfit to surface patterns. Moreover, mitigating these parsing failures via multi-agent systems incurs prohibitive latency. To address this, we propose GRAIN, a single-agent framework optimized via reinforcement learning. GRAIN models reasoning as a semantic parsing and tool-execution pipeline, guided by a Structure Invariance Reward. By validating extracted intermediate graphs against ground-truth topologies, this reward forces the LLM to learn robust text-to-structure mappings rather than memorizing linguistic artifacts. We also introduce GRIT, a benchmark evaluating sensitivity to such linguistic shifts. GRAIN outperforms multi-agent baselines by 16.45% in accuracy with approximately 24% lower latency. Furthermore, it demonstrates superior structural generalization, halving the out-of-distribution (OOD) gap of SFT models (from 15.77% to 7.80%) and maintaining robustness on large-scale graphs beyond the training distribution.

1 Introduction

Large Language Models (LLMs) exhibit great versatility in language, code, and tool utilization. However, critical domains including social network analysis, knowledge graph reasoning, and software dependency management necessitate robust reasoning over inherent graph structures. While recent approaches address classical tasks using text-serialized graphs (Wang et al., 2023), they often depend on benchmarks with sanitized identifiers. However, extracting accurate graph structures from text heavily laden with naming irregularities, alias collisions, and semantic noise is a

Existing Limitations vs. GRAIN

Figure

Figure 1: GRAIN mitigates sensitivity to naming and formulation shifts in real-world graph reasoning via a single-agent tool-use pipeline trained with isomorphism-aware structural rewards.

fundamental challenge in Information Extraction (IE) and Semantic Parsing. Such idealized settings overlook these real-world linguistic complexities, which ultimately limits reliability in practical applications. We examine the robustness gap between clean benchmarks and practical graph reasoning tasks, revealing that LLMs are surprisingly brittle to superficial variations. As shown on the left side of Figure 1, this instability stems from two sources: ① Node-label sensitivity, where altering naming schemes (e.g., Random vs. Semantic) shifts performance despite structural equivalence. ② Task-form sensitivity, where performance degrades when moving from synthetic formulations to real-world narratives. Our analysis (see Figure 2 and Table 10) highlights a distinct disparity: while closed-source models generally maintain accuracy but suffer from unpredictable variance across naming schemes, open-source models exhibit severe degradation under non-canonical settings, especially in realistic scenarios. These observations underscore the critical need to explicitly model and mitigate robustness failures caused by naming and formulation shifts.

∗^{*} Corresponding authors: Ming Liu, and Bing Qin.

Prior research investigates LLM graph representations, yet critical limitations persist. First, while textualization studies (Fatemi et al., 2024) reveal sensitivity to serialization (e.g., labeling), they typically overlook distribution shifts between standardized templates and noisy real-world formulations. Second, optimization paradigms like CoT and Supervised Fine-Tuning (SFT) struggle with structural generalization; SFT specifically overfits surface patterns, causing performance degradation under isomorphic variations, scale shifts (i.e., generalizing to graphs with significantly more nodes than the training set), or computational intensity (e.g., NP-hard problems) (Chen et al., 2024; Guo et al., 2025; Zhang et al., 2025). Finally, although multi-agent frameworks (Yuan et al., 2025b; Zhang et al., 2024a) improve accuracy via external tools, they suffer from inherent inefficiency: reliance on multi-round interactions incurs prohibitive token costs and latency, rendering them impractical for real-time deployment.

To address these limitations, we identify three critical design requirements: (i) Explicit Pipeline Modelling: Instead of relying on standard, free-form Chain-of-Thought (CoT) generation where LLMs mix logical reasoning with mental arithmetic, we decompose reasoning into explicit semantic parsing and algorithmic execution. This imposes verifiable constraints on intermediate representations, ensuring structural validity before computation. (ii) Structural Invariance: To decouple reasoning from specific identifiers, we vary naming and narratives while preserving the underlying structure, compelling the model to learn invariant rules rather than memorizing surface artifacts. (iii) Unified Agentic RL Optimization: As static supervision overfits surface forms, we employ RL with structural rewards to enforce generalization. This agentic RL formulation distills the high-accuracy reasoning capabilities—typically requiring complex multi-agent collaboration—into a single model's weights, achieving state-of-the-art performance without incurring their prohibitive latency.

Guided by these principles, we propose GRAIN (Graph Reasoning Agent with INvariance), a single-agent RL framework for robust graph reasoning. GRAIN acts as an agentic pipeline that autonomously parses noisy queries, selects optimal external algorithms, and constructs necessary structural arguments. This ensures computational correctness while focusing the LLM purely on seman-

Figure

Figure 2: Node-label Sensitivity. Large error bars reveal high instability: open-source models degrade on Random IDs, while closed-source models struggle with canonical forms.

tic parsing and information extraction. To mitigate sensitivity to surface shifts, we train GRAIN on diverse isomorphic narratives. Crucially, we optimize a unified RL objective with an invariance-oriented structural reward. By validating generated intermediate graphs against ground-truth topologies, this signal provides direct feedback on structure recovery, forcing the policy to learn invariant structural rules rather than memorizing superficial identifiers.

To facilitate systematic diagnosis, we introduce GRIT, a multi-task corpus covering six graph problems across 31 real-world prototypes. By pairing standard formulations with diverse narratives and namings, GRIT enables controlled OOD evaluation on fixed structures. Experiments demonstrate that GRAIN leverages this structural feedback to optimize the “language → structure” chain, achieving exceptional robustness against surface shifts while maintaining low computational complexity. Our primary contributions are:

• We quantify LLM sensitivity to node labeling and task formulation under a controlled isomorphic setup. We demonstrate that surface-level variations induce significant performance volatility, even when the underlying structure and semantics remain fixed.

• We propose GRAIN, a single-agent RL framework that leverages an invariance-oriented structural reward. By directly optimizing intermediate structure recovery and tool invocation, GRAIN achieves superior robustness across diverse naming schemes and task forms.

• We release GRIT, a multi-task benchmark featuring isomorphic multi-view coverage with explicit OOD splits. This resource enables systematic, reproducible evaluation of graph reasoning robustness against naming and formulation shifts.

References (41)