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:
anchors 0.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:retry events 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_exceeded as 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.
Summary
A delegated session can exceed the model context after one or more very large tool results even when
context-simplehasmax_tokens: 300000,compact_threshold: 0.8, andauto_compact: true. The resulting OpenAIcontext_length_exceedederror is then retried five times with an unchanged oversized payload.Environment
2026.07.11-c1500341.6.0anchors0.1.0gpt-5.6-sol, long context enabled)context_depth: noneReproduction
context_depth: none.invalid_request_error/context_length_exceeded.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_exceededresponse 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
context_length_exceededas non-retryable unless the request is changed.