TL;DR: A cheaper LLM can cost more in practice when agent loops, provider failover, and prompt-cache resets combine to inflate token usage and break successful completion paths, according to Sonar. The lesson is that AI agent governance now depends on response semantics, orchestration controls, and cost-per-outcome measurement, not price per token alone.
At a glance
What this is: This analysis shows how AI agent orchestration can fail when provider compatibility assumptions break, causing tool-call loss, retries, and cache fragmentation that make a cheaper model more expensive overall.
Why it matters: It matters because IAM and AI governance teams increasingly need to control non-human systems that execute tools, switch providers, and carry state across sessions, which makes runtime reliability and access semantics part of the security model.
By the numbers:
- Only 44% of developers are reported to follow security best practices for secrets management, exposing a significant developer behaviour gap.
- 17 minutes
👉 Read Sonar's analysis of AI agent provider switching, retries, and cache loss
Context
AI agent orchestration fails when runtime behaviour, not just API shape, is treated as interchangeable. In this case, the operational problem was not model quality alone but the interaction between finish semantics, tool-call handling, failover logic, and cache locality across providers. For teams governing AI agents and the identities they use to access tools, the key issue is whether orchestration assumptions survive provider changes. Sonar's example sits squarely in the emerging AI agent security problem space, where control-plane behaviour can matter as much as model output.
That matters because agentic systems are increasingly acting through tool use, delegated access, and persistent session state. When those behaviours cross provider boundaries, governance starts to resemble workload identity management as much as traditional application engineering. The security question is no longer just whether an agent can call a tool, but whether the platform can verify, preserve, and correctly interpret that action across retries, failover, and caching layers.
Key questions
Q: How should security teams handle agent failover when providers behave differently?
A: Treat failover as a runtime control, not a simple availability setting. Teams should verify how each provider handles tool calls, stop reasons, retry states, and identifier formats before routing production traffic. If those semantics differ, the harness needs normalisation and bounded retries, or the fallback path can silently create cost inflation and incomplete execution.
Q: Why do cheaper AI models sometimes cost more in production?
A: Because total cost includes retries, failed completions, cache resets, and operator time. A model that is cheaper per token but less reliable in tool-heavy workflows can burn far more compute before finishing the task. The right comparison is cost per successful outcome under the real workload, not the advertised input rate.
Q: What are the signs that an agent orchestration loop is failing?
A: Look for repeated identical tool requests, growing prompt context, dropped tool-call results, and fallback traffic that coincides with cache misses. Those patterns indicate the loop is misreading provider semantics or retrying without state recovery. In practice, the agent may appear active while silently failing to complete its work.
Q: When should teams prioritise prompt cache locality over provider switching?
A: When sessions are long-lived, tool-heavy, and sensitive to repeated context growth, cache locality often matters more than a lower per-token rate. If failover repeatedly turns warm reads into cold writes, the cheaper model can become the more expensive choice. Prioritise the cache path that preserves completion efficiency in the live environment.
Technical breakdown
Why finish_reason is not a reliable control signal
In agent orchestration, finish_reason is often treated as a terminal state, but it is really just one field in a larger response object. Some providers signal completion and tool calls separately, while others can return a stop reason even when tool_calls are present. If the loop trusts finish_reason first, it can suppress tool execution, restart the session, and create repeated retries with growing context. The architectural flaw is not the model, but the assumption that compatible response schemas imply compatible execution semantics.
Practical implication: inspect the full response body before deciding whether an agent session is complete.
How provider failover breaks prompt cache economics
Prompt caches are provider-specific, so a failover chain can convert a warm, low-cost session into repeated cold-cache requests. In long-running agent workloads, cached reads often dominate cost, which means every provider switch can reset the economics of the run. A circuit breaker that is sound for availability can still be expensive if it ignores cache locality, request frequency, and multi-subtask concurrency. The result is that a lower per-token model can become the higher total-cost choice once failover churn is included.
Practical implication: model failover and cache hit rate together, not as separate optimisation problems.
Why tool-call IDs and response formats need normalisation
Cross-provider orchestration has to normalise more than token counts. Tool-call identifiers, stop semantics, retry patterns, and error handling can differ even when vendors advertise OpenAI-compatible APIs. In practice, that means the agent harness becomes a translation layer that must preserve session integrity across providers. If IDs are not normalised, downstream tool results can fail to map cleanly back into the conversation state, and the agent can appear to work while silently losing control-flow continuity.
Practical implication: add response normalisation for tool-call IDs, stop conditions, and retry states before enabling failover.
Threat narrative
Attacker objective: The objective is not an external adversary here but an operational failure mode that drives runaway token consumption and incomplete agent execution.
- Entry occurs when an agent harness relies on a provider response contract that appears compatible but actually differs in tool-call semantics.
- Escalation happens when the orchestration loop misreads stop conditions, drops tool calls, and retries the same task with increasing context.
- Impact is repeated compute burn, failed completion, and avoidable cost inflation across provider switching and cache loss.
NHI Mgmt Group analysis
AI agent orchestration is becoming an identity and control problem, not just an LLM selection problem. Once agents can call tools, retry tasks, and switch providers, the governance challenge shifts to runtime trust, response interpretation, and delegated execution. That puts the work in range of both agentic AI governance and non-human identity management, because the agent is acting as a machine principal with tool-bearing authority. Practitioners should treat orchestration contracts as part of the access model.
Provider compatibility is a misleading shorthand for operational equivalence. The article shows that identical payloads can still behave differently in ways that break control flow, cost predictability, and state continuity. This is a classic governance gap in emerging AI systems: teams validate the interface, then assume the runtime behaves the same. The better named concept here is execution-semantics drift, where response meanings, not just formats, diverge across providers. Practitioners need to test for semantic drift before failover is allowed in production.
Cost per successful outcome is the only metric that survives real agent workloads. Token price is useful for procurement, but it becomes misleading once retries, cache churn, and incomplete tasks enter the picture. In identity terms, the system is spending more to recover from its own control assumptions than to complete the underlying job. That means cost governance for AI agents belongs beside reliability and authorisation governance, not after them.
Prompt cache locality is now a governance variable. If a provider switch destroys cache continuity, the orchestration layer is making an architectural decision with direct financial and operational impact. For agentic systems, cache behaviour should be reviewed alongside tool access, because the same runtime state that enables efficiency also expands blast radius when failover is noisy. The practitioner conclusion is to govern cache locality as part of workload identity and session management.
Autonomous retry loops magnify weak control assumptions into budget events. An agent that retries the same failing action without alternative reasoning is not merely inefficient. It is evidence that the system lacks guardrails for bounded execution, especially when tool calls and failover interact. This is where NIST AI RMF and OWASP Agentic AI guidance become relevant: the risk is not model capability alone, but unmanaged behaviour under stress. Practitioners should validate bounded retries as a control, not an optimisation.
What this signals
Execution-semantics drift is the risk pattern to watch as more organisations route AI workloads across multiple models and providers. Once the meaning of stop, tool_calls, and retry states diverges, the orchestration layer becomes the point of failure, not the model choice itself. That is a governance problem for AI agents and the identities they use, because a machine principal is only as trustworthy as the control loop interpreting its actions.
Teams should expect more cost surprises in agentic systems than in conventional application workloads. Failover logic that is sensible for resilience can quietly destroy cache efficiency and magnify token burn, which means procurement savings will keep disappearing unless runtime telemetry is attached to routing decisions. The strongest control pattern is to manage provider switching as a stateful access and execution event, not a behind-the-scenes transport choice.
For practitioners
- Validate response semantics before enabling failover Test whether finish_reason, tool_calls, and error states mean the same thing across every provider in your routing chain. Treat the response body as authoritative and require the agent harness to execute tool calls even when stop is returned alongside them.
- Measure cost per successful outcome Track total tokens, retries, cache writes, cache reads, and engineering time per completed task. Use those numbers to compare providers under real workload conditions, not synthetic benchmarks or per-token pricing alone.
- Normalise tool-call identifiers across providers Map provider-specific tool-call IDs into a stable internal format before results are appended back into conversation state. Without that translation layer, cross-provider sessions can lose continuity even when the model output looks valid.
- Model failover as a cache-risk event Simulate rate-limit triggers, circuit breaker trips, and repeated provider switching to see how often prompt caches go cold. Use the results to decide whether availability failover is worth the input-price penalty in long-running sessions.
- Bound retry loops in agent orchestration Set explicit ceilings on repeated tool failures, identical retries, and context growth per session. If the same action fails more than once without a new path, stop the loop and surface the incident to an operator.
Key takeaways
- AI agent provider compatibility is not enough when response semantics, tool handling, and retry behaviour differ across vendors.
- A cheaper model can become more expensive once cache churn, infinite retries, and engineering overhead are included in the total cost.
- Practitioners should govern agent orchestration as a runtime control problem, with semantic validation, bounded retries, and cache-aware failover.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10 address the attack surface, NIST AI RMF, NIST SP 800-53 Rev 5 and NIST CSF 2.0 set the technical controls, and ISO/IEC 42001:2023 define the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | Agent tool use and execution safety | The article centres on agent tool handling, retry loops, and runtime behaviour drift. |
| Recommendation — Map agent routing and tool execution to OWASP Agentic AI controls and require semantic validation before failover. | ||
| NIST AI RMF | MANAGE — AI Risk Management and Monitoring | Runtime retries, cache loss, and cost overruns require ongoing AI risk management. |
| Recommendation — Monitor live agent behaviour under failover and enforce controls for bounded execution and operational drift. | ||
| NIST SP 800-53 Rev 5 | AU-12 — Audit Record Generation | Observability of retries, tool calls, and cache churn is necessary to detect orchestration failures. |
| Recommendation — Generate audit records for tool calls, retries, and provider switches so orchestration failures are traceable. | ||
| NIST CSF 2.0 | PR.AC-4 — Access Permissions and Authorisations | The agent is a machine principal whose delegated tool access must be governed. |
| Recommendation — Apply PR.AC-4 to bound agent tool permissions and verify delegated access before execution. | ||
| ISO/IEC 42001:2023 | 8.2 — AI risk treatment | The article highlights governance of AI operational risk, including routing and runtime controls. |
| Recommendation — Document routing, failover, and cost controls as part of the AI management system and review them continuously. | ||
Key terms
- Execution-Semantics Drift: A mismatch between what an API response appears to mean and how an orchestration system actually behaves when it processes it. In agentic systems, this usually shows up when different providers use the same fields but attach different runtime meaning to stop conditions, tool calls, retries, or error states.
- Prompt Cache Locality: The degree to which a session can keep using the same provider-side cache across consecutive requests. In long-running AI workloads, locality determines whether the system keeps paying for cached reads or repeatedly re-establishes fresh context at full input cost after routing changes or failover.
- Bounded Retry Loop: A retry mechanism that stops after a defined number of repeated failures instead of continuing indefinitely. For AI agents, bounded retries are essential because identical repeated actions can consume large amounts of compute, hide control-flow bugs, and create runaway operational cost without improving task completion.
- Tool-Call Normalisation: The process of converting provider-specific tool invocation identifiers and response structures into one internal format. This allows agent harnesses to preserve state across providers and avoid silent loss of action context when sessions switch between models or routing paths.
What's in the full article
Sonar's full analysis covers the operational detail this post intentionally leaves for the source:
- The exact Rust harness logic used to route requests, handle failover, and manage provider-specific response handling.
- Side-by-side examples of how Claude and Kimi differed on finish semantics, tool-call placement, and retry behaviour.
- The weekend test conditions that exposed cache invalidation and the resulting cost impact across real PR workloads.
- The practical reasoning behind returning to Claude across the production workload.
Deepen your knowledge
The NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, machine identity security, and secrets management. It helps practitioners connect identity controls to the operational realities of agentic systems and delegated access.
Published by the NHIMG editorial team on September 11, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org