Skip to content

[Bug] A2A session causes insufficient_runtime_budget due to unbounded pending history #947

Description

@Clawiee

Bug Description

Agent collaboration fails with error:

❌ Agent collaboration failed: insufficient_runtime_budget

This error only occurs in one specific A2A conversation, while other conversations work normally.


Root Cause Analysis

Why Only This Conversation Triggers

The capture_run_inputs logic in context_builder.py:

  • direct sessionrecent_messages = () (no history loaded)
  • group session → same as above, no history loaded
  • A2A session → uses load_context_pack, sets watermark via covered_through_message_id, returns ALL history as pending when not compacted (watermark=NULL)

This A2A conversation has never been compacted (covered_through_message_id is NULL), so all 321 messages become pending history.

Regular direct/group sessions or already-compacted sessions don't trigger this — explaining why only this conversation fails.

Why It Appears in v1.11

v1.11 introduced a new runtime_budget hard validation check in model_capabilities.py. This validation didn't exist before, so the issue was hidden in previous versions.

Safety of Investigation

All operations were read-only:

  • SELECT + checkpoint decoding only
  • No data written, no code modified
  • Only 6 test API calls to kimi-k3 (minimal token consumption)
  • Temporary scripts have been cleaned up

Suggested Fixes (For Decision, Not Yet Implemented)

The root issue is unbounded pending history in uncompacted A2A sessions. Possible solutions:

  1. Option A (Recommended): Execute compact / set watermark for A2A sessions as well (fix at platform level)
  2. Option B: Add limits to pending_session_messages_snapshot (limit by count or token budget) (fix in code)
  3. Option C: Set context_window_tokens_override for the model (workaround, increases input_limit to bypass 114k cap)

Reporter

xiaoan (Platform User)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions