fix: cap oversized ACP event content instead of failing the send#437
Closed
AlexanderZ-Band wants to merge 1 commit into
Closed
fix: cap oversized ACP event content instead of failing the send#437AlexanderZ-Band wants to merge 1 commit into
AlexanderZ-Band wants to merge 1 commit into
Conversation
c038f86 to
0714f74
Compare
…-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>
0714f74 to
5fface7
Compare
This was referenced Jul 14, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /agent/chats/{id}/events) hard-capscontentat 16384 chars and rejects anything larger with a 422 — the ACP/GitHub Copilot backend hit this when mirroring largetool_call/tool_resultpayloads (e.g. a GitHub MCPget_file_contentscall on a big file), causing the send to fail outright instead of degrading gracefully.contentstring 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.send_eventcalls 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