Skip to content

fix: reconstruct parallel tool-call assistant message from split core messages - #1

Merged
ranxianglei merged 1 commit into
masterfrom
2026-07-31_parallel-toolcall-reconstruction
Jul 31, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-07-31_parallel-toolcall-reconstruction

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

  • Fix: coreOutToAgentMessages() was dropping parallel tool-call messages, causing 400 errors on the next LLM turn
  • Root cause: projectMessage() splits assistant parallel tool-calls into core messages with id entryId#callId, but originalById map keyed by entry.id only → lookup fails → messages dropped → orphaned tool results → 400

Fix

Rewrote coreOutToAgentMessages() to detect #callId suffix, group by base entry ID, and reconstruct ONE assistant message with all surviving toolCall blocks + text blocks + ref tag. Handles partial pruning (some tool-calls compressed, others survive).

Tests

  • 2 new regression tests: full reconstruction (3 parallel calls → 1 message) + partial pruning (2 of 3 survive)
  • All 16 tests pass, typecheck clean

… messages

projectMessage() splits assistant parallel tool-calls into individual core
messages with id format 'entryId#callId'. coreOutToAgentMessages() was using
originalById.get(core.id) which failed for split IDs (map keyed by entry.id
only). This dropped all parallel tool-call messages, orphaning their tool
results → 400 from LLM API on the next turn.

Fix: detect '#callId' suffix, group by base entry ID, reconstruct ONE assistant
message with all surviving toolCall blocks + text blocks, apply ref tag.
Handles partial pruning (some tool-calls compressed, others survive).

Tests: 2 new regression tests (full reconstruction + partial pruning).
@ranxianglei
ranxianglei merged commit f972363 into master Jul 31, 2026
Zeno2019 pushed a commit to Zeno2019/billion-context-pi that referenced this pull request Aug 7, 2026
Replace standalone brand 'ACP' / 'Active Context Pruning' with
'billion-context' / 'Billion-Context' in README prose, reflecting the
pai-acp -> billion-context-pi rename (v0.1.24).

Kept technical identifiers as-is: /acp command + its output banner,
tool names (acp_status, acp_delegate*), acp.json, ACP_* env vars,
acp-kernel library.

Refs ranxianglei#1.
HangxiangMa pushed a commit to HangxiangMa/billion-context-pi that referenced this pull request Sep 21, 2026
Replace standalone brand 'ACP' / 'Active Context Pruning' with
'billion-context' / 'Billion-Context' in README prose, reflecting the
pai-acp -> billion-context-pi rename (v0.1.24).

Kept technical identifiers as-is: /acp command + its output banner,
tool names (acp_status, acp_delegate*), acp.json, ACP_* env vars,
acp-kernel library.

Refs ranxianglei#1.
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