fix(agent): rebuild resume transcripts from ACP top-level tool fields#3084
Merged
Conversation
Session JSONL hydration read toolCallId/toolInput/toolResponse from _meta.claudeCode, but ACP puts toolCallId, rawInput, and rawOutput on the update object itself (meta only reliably carries toolName). Every tool call was dropped, so a 30-minute run resumed as a 4-line transcript and the agent re-derived everything from scratch. Also cap individual tool payloads at 10k chars and make selectRecentTurns degrade an over-budget final turn by shedding its oldest tool calls instead of returning an empty selection. Generated-By: PostHog Code Task-Id: 9111837d-6522-400e-8495-ea6f1cfd6e17
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "fix(agent): rebuild resume transcripts f..." | Re-trigger Greptile |
…ipts
Review follow-up: capToolPayload replaced oversized object inputs with a
truncated string, but tool_use.input must stay an object per the Claude
API schema. Wrap truncated non-string payloads in
{ _truncated, preview, originalSize } instead.
Generated-By: PostHog Code
Task-Id: 9111837d-6522-400e-8495-ea6f1cfd6e17
There was a problem hiding this comment.
Fix correctly extends the SessionUpdate interface to read ACP top-level fields and adds a robust fallback for oversized single-turn transcripts. The greptile bot's object-truncation concern was genuinely addressed, and the new tests cover both the ACP shape and the truncation/fallback behaviors.
Contributor
|
Reviews (2): Last reviewed commit: "fix(agent): keep truncated tool inputs a..." | Re-trigger Greptile |
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.
Problem
When a cloud run resumes into a successor run, the agent server rebuilds the prior Claude session JSONL from the run's S3 event log (
hydrateSessionJsonl). The rebuild readtoolCallId/toolInput/toolResponsefrom_meta.claudeCode, but in the logs agent-server actually persists, ACP putstoolCallId,rawInput, andrawOutputon the update object itself._meta.claudeCodeonly reliably carriestoolName.Result: every tool call was silently dropped from the rebuilt transcript. A real 30-minute run with 7,522 log entries and 97 tool calls hydrated to a 4-line transcript (the prompt plus ~2KB of assistant prose), so the resumed agent greeted the user, found a clean tree, and re-implemented the whole task from scratch.
Changes
rebuildConversationnow readstoolCallIdfrom the update (falling back to meta for older logs), takes input fromrawInput(skipping the empty{}the openingtool_callships so it can't clobber streamed input), and results fromrawOutputormeta.toolResponseselectRecentTurnsgets a fallback for the shape every single-prompt run produces (one user turn plus one giant assistant turn): when the final turn alone exceeds the token budget it now sheds the oldest tool calls until it fits, instead of selecting zero turns and writing an empty transcript