Defining Tool Call Nesting Depth
Tool call nesting depth describes the number of sequential or recursive tool invocations an AI agent executes within a single task before returning a final response. In agentic systems, a model does not simply answer a query. It can call a tool, receive a result, and use that result to decide whether to call another tool, which may itself trigger further calls. Nesting depth is the measure of how many of these steps occur in a chain.
No major orchestration framework currently uses "nesting depth" as a formally standardized metric. LangGraph refers to a recursion limit measured in super-steps. AWS Bedrock Agents describes orchestration iterations. Microsoft Semantic Kernel uses a maximum iteration count for auto function calling. OpenAI's function calling documentation describes multi-turn tool loops but leaves iteration control to the developer. These are functionally equivalent concepts expressed with different terminology, and most are implemented as an integer cap on steps or iterations rather than a true call-stack depth measurement.
Why Unbounded Nesting Is an Enterprise Problem
Chained tool calls create a control-flow pattern that behaves differently from a single request-response interaction. When a tool's output feeds back into the agent's reasoning and that reasoning triggers another tool call, the sequence can continue indefinitely if nothing forces it to stop. LangChain's own documentation notes that agent executors can enter infinite loops when tool outputs repeatedly generate further tool calls that never resolve to a final answer.
The operational consequences are concrete rather than theoretical. Each additional tool call and its result consumes context window tokens, so deeper chains increase both latency and cost per task, as OpenAI's documentation confirms. Uncontrolled chains also increase security exposure, since every additional tool invocation is an additional opportunity for the agent to access data or systems it was not explicitly scoped to use. OWASP's Excessive Agency category in its LLM application guidance identifies this pattern directly, describing risk that arises when agents are given functionality, permissions, or autonomy without adequate constraints.
How Runtime Environments Enforce Depth Limits
Nesting or recursion limits are enforced at the orchestration layer, meaning the agent executor or graph runtime that manages the sequence of tool calls, rather than within the underlying language model. LangGraph raises a GraphRecursionError once a configured recursion limit is exceeded. AWS Bedrock Agents supports configurable limits on the number of orchestration iterations within its agent loop. Semantic Kernel applies a maximum iteration count to its auto function calling behavior. In each case, exceeding the configured limit typically produces a runtime exception rather than a silent truncation, which allows the calling application to handle the failure explicitly.
Frameworks generally do not architecturally distinguish between linear tool chains, where calls proceed one after another, and recursive chains, where a tool call triggers another agent invocation. Both are counted against the same iteration or recursion limit. This means the limit functions as a blunt but effective backstop rather than a fine-grained structural control.
Nesting Limits Are Not a Substitute for Permission Scoping
A depth limit constrains how long a chain of tool calls can run, but it does not constrain what those calls are permitted to do. Semantic Kernel's documentation notes that function-calling loops execute under the identity and permission scope of the calling application, meaning nested calls do not automatically acquire new authorization context. In practice, this means a recursion limit can stop a runaway chain, but every call within that chain still carries whatever access the originating agent had from the start.
This distinction matters for enterprise governance. NIST's AI Risk Management Framework calls for organizations to map and manage risks from AI system behaviors, including cascading or unanticipated actions, as part of ongoing risk measurement. Treating nesting depth limits and permission scoping as separate but complementary controls, rather than assuming one substitutes for the other, aligns with that framing. A well-scoped agent with a generous depth limit may be lower risk than a narrowly-limited agent with broad, unscoped tool access.
Where Runtime Governance Fits
Nesting depth limits are one control among several needed to govern how AI agents behave at runtime. They address a specific failure mode, uncontrolled or recursive execution, but they operate independently from identity, permission scope, and audit logging. Trussed AI provides runtime governance for enterprise AI agents, including runtime policy enforcement, agent identity and permissions, least privilege controls, tool approval workflows, and audit logging. These capabilities are relevant to the concerns raised in this guide because they address the layers surrounding a depth limit, such as what an agent is authorized to do at each step and how that activity is recorded for review, rather than the iteration count itself.