SAP researchers teach AI agents to stop flip-flopping between different solutions to the same task
A researcher at SAP has proposed a way to test how stable an AI agent really is: give it the same task several times in a row and see whether it acts consistently or picks different tools and gives contradictory answers each time. The method is called Recursive Semantic Divergence (RSD). The idea is to run the agent twice from the same point in a conversation and compare not the exact wording but the meaning of its actions, using a natural language inference (NLI) model to spot logical contradictions. If the two runs contradict each other now or in future steps, the agent gets a high divergence score. That score was built into the reward signal during training with the GRPO method, and after this fine-tuning, the variance in results (coefficient of variation) dropped from a noticeable level to a low one on the τ-bench and ToolSandbox benchmarks — without hurting task-solving performance, which in some cases even improved. • Experiments were run on Qwen-2.5 models with 3 billion and 7 billion parameters. • For each task, the agent was run 8 times independently to measure behavioral variance. • RSD was compared against unsupervised approaches using token entropy and semantic entropy — RSD came out ahead because it accounts for how divergence builds up across an entire conversation, not just within a single response.
AI-processed from arXiv cs.CL; edited by Hamidun News
If you ask an AI agent with access to tools (search, databases, APIs) to solve the same task multiple times, it can behave differently every single time — calling different functions, giving the user contradictory answers, or reaching the result through entirely different paths. For a casual chatbot, that's a minor annoyance. But for an agent handling medical data or writing code across multiple steps, this kind of unpredictability is a serious problem: an error at one step compounds and pulls the whole solution off course.
The paper's author, Harshavardhan Abhichandani of SAP, noticed that existing methods for evaluating agents almost always measure just one thing: whether the agent solved the task or not. Almost nobody asks whether the agent behaves consistently from run to run. Even setting the generation temperature to zero (deterministic mode) doesn't fix this — random tool responses, environment noise, or even technical quirks like GPU floating-point precision still destabilize the agent's behavior over a long sequence of steps.
How RSD works
The idea borrows from reinforcement learning theory, specifically the concept of bisimulation — a way to compare two states of a system based on how similarly they'll behave in the future, rather than how they look right now. The author adapted this idea for conversational agents:
- The agent is run twice in a row from the exact same point in a conversation (the same message and action history).
- At each step, instead of comparing text, the method compares the meaning of the two agent responses using a natural language inference (NLI) model, which determines whether two statements contradict each other, agree, or are simply unrelated.
- The divergence at the current step is combined (with a decaying weight) with the expected divergence at all subsequent steps, producing a recursive formula similar to how reinforcement learning computes cumulative future reward.
- Since it's impossible to compute this sum exactly for a language model — which behaves as a black box over an enormous space of possible conversations — the author trains a separate neural network to approximate this divergence using temporal-difference (TD) learning, similar to how a Q-function is trained.
The result is a single number for each conversation state — a score for how "predictably" the agent is likely to behave going forward. If the agent always picks the same tool with the same arguments (even if phrased differently), the score approaches zero — fully consistent behavior. If the agent flip-flops between different strategies and contradicts itself, the score climbs.
The key practical payoff: at inference time, computing this score requires just a single forward pass of the model — no repeated runs, comparisons, or NLI calls needed. That means the consistency score can be built into an agent's workflow with negligible overhead.
What the experiments showed
The author tested the approach on Qwen-2.5 models with 3 billion and 7 billion parameters across two tool-use agent benchmarks — τ-bench and ToolSandbox. For each task, 8 independent runs were conducted (across 8 test examples, yielding 64 trajectories per benchmark) to get a reliable measure of behavioral variance.
RSD was used as an additional reward signal during fine-tuning with GRPO (Group Relative Policy Optimization), penalizing the model for high divergence between its own repeated runs. It was compared against three alternatives:
- the base Qwen model with no fine-tuning;
- fine-tuning via token entropy minimization (a classic way to measure a model's "confidence" from its probability distribution);
- fine-tuning via semantic entropy (clustering the meaning of a single response without accounting for future steps);
- standard supervised fine-tuning (SFT) on labeled data.
The result: fine-tuning with RSD reduced the coefficient of variation (a measure of result-to-result spread) on both benchmarks — τ-bench and ToolSandbox — matching the results achieved by SFT, but without requiring any labeled reference data. Meanwhile, overall task-solving success (completion rate and speed of progress) didn't drop, and in some configurations actually improved.
Why it matters
For teams building production LLM-based agents — especially in domains where mistakes are costly, like finance, healthcare, or back-office automation — this is a practical diagnostic tool for assessing how predictable an agent is before it fails in front of a real user. The main caveat: the approach has only been validated on relatively small models (3B and 7B parameters) and two specific benchmarks, so its scalability to larger models and more diverse scenarios still needs to be confirmed. The code has been released publicly in the RSD-agent-consistency repository on GitHub.
- Oct 29, 2026ElevenLabs hands routine work to internal agents and saves 1,200 hours a month
- Oct 29, 2026GitLab Orbit hits GA: agents need 4.5x fewer tokens
- Oct 29, 2026Developer builds a RAG system on local models, boosting search accuracy from 20% to 53%
- Oct 29, 2026OES Puts 30 AI Agents on Mining Haul Trucks and Lifts Haulage by 10%
Key Questions Answered
How RSD works?
The idea borrows from reinforcement learning theory, specifically the concept of bisimulation — a way to compare two states of a system based on how similarly they'll behave in the future, rather than how they look right now. The author adapted this idea for conversational agents: The agent is run twice in a row from the exact same point in a conversation (the same message and action history). At each step, instead of comparing text, the method compares the meaning of the two agent responses using a natural language inference (NLI) model, which determines whether two statem
What the experiments showed?
The author tested the approach on Qwen-2.5 models with 3 billion and 7 billion parameters across two tool-use agent benchmarks — τ-bench and ToolSandbox. For each task, 8 independent runs were conducted (across 8 test examples, yielding 64 trajectories per benchmark) to get a reliable measure of behavioral variance. RSD was used as an additional reward signal during fine-tuning with GRPO (Group Relative Policy Optimization), penalizing the model for high divergence between its own repeated runs. It was compared against three alternatives: the base Qwen model with no fine-tu
Why it matters?
For teams building production LLM-based agents — especially in domains where mistakes are costly, like finance, healthcare, or back-office automation — this is a practical diagnostic tool for assessing how predictable an agent is before it fails in front of a real user. The main caveat: the approach has only been validated on relatively small models (3B and 7B parameters) and two specific benchmarks, so its scalability to larger models and more diverse scenarios still needs to be confirmed. The code has been released publicly in the RSD-agent-consistency repository on GitHu
Delegate Deep Research, Coding & Multi-Step Workflows to Nomad Agent
Deploy autonomous task execution with Nomad Agent (agent.nomadnet.ai) — automated web research, data synthesis, code generation, and MCP tool orchestration.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.