microsoft / microsoft/amplifier
Large tool results bypass auto-compaction and context_length_exceeded is retried unchanged
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.1k
- Forks
- 261
- Avg merge
- 3h 28m
- Merged PRs (30d)
- 13
Description
Summary
A delegated session can exceed the model context after one or more very large tool results even when context-simple has max_tokens: 300000, compact_threshold: 0.8, and auto_compact: true. The resulting OpenAI context_length_exceeded error is then retried five times with an unchanged oversized payload.
Environment
- Amplifier CLI:
2026.07.11-c150034 - amplifier-core:
1.6.0 - Bundle:
anchors0.1.0 - Provider: OpenAI (
gpt-5.6-sol, long context enabled) - Delegation: fresh child with
context_depth: none - OS: Linux / WSL2
Reproduction
- Start a fresh delegated child with
context_depth: none. - Have the child run content searches over JSONL files whose individual matching lines are very large.
- In the observed run, two search tool results were approximately 614,299 and 735,454 characters.
- Observe provider input usage grow from 57,519 tokens to 441,952 and then 827,426 despite the bundle's 300,000-token context setting and auto-compaction.
- After one more iteration, OpenAI returns
invalid_request_error/context_length_exceeded. - Observe five
provider:retryevents replaying the same deterministic failure.
No raw session contents are attached because they may contain private data; the sizes and usage counts above come from event metadata only.
Expected behavior
Before every provider submission, Amplifier should ensure the serialized request is within the effective provider/model context budget. Large tool results should be truncated, artifactized, or trigger compaction before the next request. A context_length_exceeded response should be non-retryable unless Amplifier first reduces the payload.
Actual behavior
Tool results can push a delegated session far beyond the configured context budget without compaction. The oversized provider request fails, then the same payload is retried five times.
Suggested safeguards
- Enforce a configurable byte/token cap on every tool result, independent of result line count.
- Run a final provider-specific token-budget check immediately before submission.
- Compact or artifactize oversized tool results before sending.
- Classify
context_length_exceededas non-retryable unless the request is changed. - Add a regression test with a single very large tool result and another with multiple medium-large results.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing delegated-session context handling from tool-result processing through the final provider submission, then inspect the retry path for context_length_exceeded. Reproduce with one very large result and with multiple medium-large results; done means requests stay within the effective context budget and unchanged context-length failures are not retried.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai-infra-agents
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100