[FEATURE] Add an invocation-tree budget and descendant usage total
SDK Language
Python
Problem Statement
Strands limits and EventLoopMetrics are scoped to one Agent invocation. Nested Agents have independent limits and metrics, while auxiliary model calls such as conversation summarization may bypass Agent metrics entirely. As a result, the root Agent cannot constrain or report the complete usage caused by its invocation.
Examples include:
- An Agent delegated through an Agent-as-tool or
subagent. - The analyst Agent used by prompted
web_fetch. - The direct model call used for conversation summarization.
Applications currently need to maintain their own synchronized budget and manually collect usage from every nested worker. This requires each SDK capability to expose its worker construction or callbacks, and a missed integration silently produces incomplete limits and usage.
Proposed Solution
Add a request-scoped invocation context that nested Agents and auxiliary model calls can join. It should:
- Apply one shared turn and token budget across every model call caused by the root invocation.
- Debit actual usage after each model call so subsequent calls observe the remaining budget.
- Preserve each Agent's local usage and existing per-model-call telemetry.
- Expose clearly separated root, descendant, and invocation-total usage without double counting.
- Automatically propagate through SDK-owned paths such as Agent-as-tool, prompted
web_fetch, and conversation summarization.
The context should remain available to direct model-call helpers so a capability does not need to construct an Agent solely to participate in limits and accounting.
Use Case
A managed harness accepts invocation-wide iteration and token limits and returns one authoritative usage total to the customer. Those limits and usage must cover every billable model call caused by the request, including delegated Agents and SDK-owned auxiliary calls.
For example, if the root Agent calls prompted web_fetch and then delegates a task, the root result should expose:
- The root Agent's usage.
- Each descendant's usage.
- One invocation total covering all three Agents.
All calls should debit the same budget before the root Agent continues.
Alternatives Solutions
Callers can attach shared hooks and accounting callbacks to every worker. This works when worker construction is exposed, but it is easy to miss and requires every SDK capability to provide a separate integration point.
Another option is to add feature-specific factories for web_fetch and summarization. That provides short-term extensibility but does not establish one consistent contract for future auxiliary model calls.
Additional Context
- Native per-Agent limits: https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/types/agent.py
- Per-Agent metrics: https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/telemetry/metrics.py
- Prompted
web_fetch: https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/vended_tools/web_fetch/web_fetch.py - Conversation summarization: https://github.com/strands-agents/harness-sdk/blob/main/strands-py/src/strands/agent/conversation_manager/summarizing_conversation_manager.py