Summary
Add smarter truncation for oversized tool outputs. Today max_old_tool_call_tokens is opt-in and only replaces OLDER tool results wholesale with "[content truncated]"; there is no cap on a single large tool output at ingest and no middle-out truncation.
Proposed behavior
- Add a per-result cap with middle-out truncation (keep head + tail, drop the middle) for oversized single tool outputs at ingest.
- Decision: keep defaults OFF — ship this opt-in first. A non-zero default for
max_old_tool_call_tokens is explicitly deferred (would be a behavior change for existing users).
Implementation notes (starting points)
pkg/session/session.go (truncateOldToolContent at ~1290-1293, 1536-1540; add an ingest-time cap)
- Config key(s) in
pkg/config/latest/types.go + agent-schema.json + example YAML
- Must NOT weaken the kept-suffix turn-boundary logic (
SplitIndexForKeep in pkg/compaction)
Complexity: M.
Background: shared plan context-management-gap-analysis (Phase 2, item 5).
Dependencies / Relationships
- Independent — no dependencies on the other context-management issues.
Summary
Add smarter truncation for oversized tool outputs. Today
max_old_tool_call_tokensis opt-in and only replaces OLDER tool results wholesale with "[content truncated]"; there is no cap on a single large tool output at ingest and no middle-out truncation.Proposed behavior
max_old_tool_call_tokensis explicitly deferred (would be a behavior change for existing users).Implementation notes (starting points)
pkg/session/session.go(truncateOldToolContentat ~1290-1293, 1536-1540; add an ingest-time cap)pkg/config/latest/types.go+agent-schema.json+ example YAMLSplitIndexForKeepinpkg/compaction)Complexity: M.
Background: shared plan
context-management-gap-analysis(Phase 2, item 5).Dependencies / Relationships