Skip to content

fix: cap oversized ACP event content instead of failing the send#437

Closed
AlexanderZ-Band wants to merge 1 commit into
devfrom
feat/github-copilot-with-acp-throughs-string-length-is-INT-1014
Closed

fix: cap oversized ACP event content instead of failing the send#437
AlexanderZ-Band wants to merge 1 commit into
devfrom
feat/github-copilot-with-acp-throughs-string-length-is-INT-1014

Conversation

@AlexanderZ-Band

@AlexanderZ-Band AlexanderZ-Band commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The Agent Events API (POST /agent/chats/{id}/events) hard-caps content at 16384 chars and rejects anything larger with a 422 — the ACP/GitHub Copilot backend hit this when mirroring large tool_call/tool_result payloads (e.g. a GitHub MCP get_file_contents call on a big file), causing the send to fail outright instead of degrading gracefully.
  • The 16384 cap isn't an arbitrary number tied to a technical limit — it's a deliberate guardrail. Every event broadcasts over the room's WebSocket channel to every connected socket, so an unbounded content string is a fan-out amplification vector. Per the platform source (thenvoi-platform/lib/thenvoi_com_web/controllers/api/v1/agent/events_controller.ex:34-39): "The caps are generous ceilings (no legitimate event hits them), purely to stop pathological payloads from being broadcast." The Copilot CLI's large tool_result is exactly the legitimate-but-oversized case that guardrail didn't anticipate.
  • AgentTools.send_event (src/band/runtime/tools.py) — the single chokepoint every adapter funnels through — now truncates oversized content to the cap (keeping the head, dropping the tail with a "... [truncated]" marker) before sending, rather than throwing.
  • Fixes the root cause generically for every adapter, not just ACP, since all send_event calls share this one path.

Linear: INT-1014

Test plan

  • uv run pytest tests/runtime/test_tools.py -k SendEvent -v --no-cov — new truncation tests pass (pass-through under the cap, oversized content truncated with marker)
  • uv run pytest tests/ --ignore=tests/integration/ --ignore=tests/e2e/ -q --no-cov — full suite (3800 passed, 75 skipped)
  • uv run ruff check . / uv run ruff format --check .
  • uv run pyrefly check

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Jul 14, 2026

Copy link
Copy Markdown

INT-1014

@AlexanderZ-Band AlexanderZ-Band changed the base branch from main to dev July 14, 2026 12:42
@AlexanderZ-Band AlexanderZ-Band force-pushed the feat/github-copilot-with-acp-throughs-string-length-is-INT-1014 branch 2 times, most recently from c038f86 to 0714f74 Compare July 14, 2026 12:47
…-1014]

The Agent Events API rejects content over 16384 chars with a 422, which the
ACP/GitHub Copilot backend hit when mirroring large tool_call/tool_result
payloads (e.g. get_file_contents on a big file). AgentTools.send_event now
truncates oversized content at the shared chokepoint, keeping both the head
and tail of the string so the tail (often the informative part of a raw
error dump) isn't silently dropped.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@AlexanderZ-Band

Copy link
Copy Markdown
Collaborator Author

Superseded by #439, which combines this with #423 into a single PR against dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant