Skip to content

Bug Report: Context Overflow from Unbounded Tool Outputs #9140

@Bowiemb

Description

@Bowiemb

Date: 2026-02-04
Version: 2026.2.2-3
Severity: High (breaks agent completely)

Summary

Large tool outputs are not truncated before being added to context, causing sessions to overflow the 200k token limit even with compaction enabled.

Reproduction

  1. Use sessions_list with many sessions or gateway config.get repeatedly
  2. Session file grows unbounded
  3. Eventually hits HTTP 400 invalid_request_error: prompt is too long: 225881 tokens > 200000 maximum

Evidence

From session session-id (4.5MB):

Line Size Tool
877 1.1MB sessions_list
857 640KB gateway (config.get)
357 616KB gateway (config.get)
319 266KB exec

Compaction ran 4 times but couldn't shrink single-turn payloads.

Config

"compaction": {
  "mode": "safeguard",
  "memoryFlush": {
    "enabled": true,
    "softThresholdTokens": 20000
  }
}

Expected Behavior

  1. Tool outputs should be truncated to a reasonable size (e.g., 50KB) before context insertion
  2. Or compaction should aggressively summarize/drop large tool results
  3. Warning when a single tool call exceeds threshold

Suggested Fix

  • Add maxToolOutputBytes config (default ~50KB)
  • Truncate with [truncated: X bytes remaining] indicator
  • Log warning when truncation occurs

Workaround

Run /new to start fresh session. Archive old sessions manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions