Skip to content

Commit ed36ed5

Browse files
committed
feat(opencode): add chunking rule for large write tool calls
OpenCode's tool-call streaming over @ai-sdk/anthropic via GitHub Copilot truncates large 'write' payloads at the 32 000 output-token cap, leaving an orphaned tool call that the agent sees as 'Tool execution aborted' with no recoverable state (upstream issue anomalyco/opencode#33687). Empirical evidence on this host across 30+ days: 9 of 10 orphaned writes hit output=32000, finish=length. Successful writes go up to ~58 KB but the tail is thin and unreliable. 20 KB / 400 lines is a conservative threshold that leaves plenty of token headroom for reasoning and pre- text on the same turn. The rule tells the agent to emit the first chunk with 'write' and append the remainder with a 'bash' heredoc, which avoids the streaming path that triggers the bug.
1 parent 5752f01 commit ed36ed5

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎private_dot_config/AGENTS.md.tmpl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ When producing prose, invoke the `humanizer` skill. Never use em dashes.
1010
- Update plan documentation as you go.
1111
- Learn from existing implementations and style.
1212
- Stop after 3 failed attempts and reassess.
13+
- Chunk large file writes. If a `write` tool call's `content` would exceed about 400 lines or 20 KB, split it: emit the first chunk (≤200 lines / ~10 KB) with `write`, then append the remainder with `bash` using `cat >> path << 'EOF' ... EOF`. OpenCode's tool-call streaming over `@ai-sdk/anthropic` via GitHub Copilot truncates large writes at the 32 000 output-token cap, leaving an orphaned tool call (upstream issue anomalyco/opencode#33687). The model sees `"Tool execution aborted"` with no recoverable state.
1314

1415
## Never
1516

0 commit comments

Comments
 (0)