Repository navigation
Sync with Python SDK 0.2.174 - #181
Conversation
The conversation goes on from the tool result written last. When that result answers an earlier call than the batch's last, the tool_use entries written after it are off the parentUuid path, and #157's re-attachment (which only adds off-chain results of on-chain calls) never saw them: the session readers dropped those calls and their results. About 7% of the parallel batches in local transcripts have this shape. The off-chain entries of every API message on the chain now go back right after its last on-chain entry, in timestamp order, before the results are re-attached. A result the CLI parented on a hook attachment is matched to its call by tool_use_id when the same agent wrote both. A later call going on from an earlier result of its own batch no longer counts as a branch that went on. #157's guards are unchanged, and the subagent readers get the fix too (Python's do not). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PQPc2HryX1S85K3x1FqRfT
…essionStart/Setup on (Python #1336) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PQPc2HryX1S85K3x1FqRfT
On real transcripts the dropped-branch guard (#157) kept out results it was meant to return: 105 under a meta entry (the "[Image: ...]" note the CLI writes under a screenshot result) and a result another result of the same batch was parented under (via its hook attachment). Neither goes on from the result. continued_from now passes through meta entries as it does through attachments, so a branch that goes on through one is still found, and results for calls of the chain are not continuers. Across 7474 local transcripts, tool calls returned without a result go from 319 (before this branch) to 43: 32 still running at the end of the session, 11 whose result heads a branch with an assistant reply off the chain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PQPc2HryX1S85K3x1FqRfT
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 992e1bf96a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| batch = entries.select { |entry| entry['type'] == 'user' && answers_chain_call?(entry, owners) } | ||
| continued = continued_from(entries, except: on_chain | batch.map { |entry| entry['uuid'] }) |
There was a problem hiding this comment.
Preserve dropped-branch detection across consecutive tool results
When an abandoned branch contains result_a -> hook attachment -> result_b -> assistant reply, and a rewind continues from the batch's tool calls with a new prompt, excluding every batch result from continued_from hides the continuation from result_a to result_b. Only result_b is marked as continued, so result_a is incorrectly reattached to the current conversation even though its branch was dropped. I reproduced this with the transcript fixture: the parent revision excludes both abandoned results, while this revision returns the old result for call A. Preserve continuation detection through excluded batch results when their branch ultimately leads to an abandoned reply.
Useful? React with 👍 / 👎.
A result of the batch parented under an earlier result's hook attachment no longer marked that earlier result as the head of a dropped branch, so on a branch a rewind dropped (result_a -> attachment -> result_b -> reply) only result_b stayed out and result_a was put back. Such a result now counts as going on from the earlier one once something goes on from it in turn. Same output as before on all 7479 local transcripts. Reported by the Codex review on PR #181. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PQPc2HryX1S85K3x1FqRfT
Syncs the gem with Python SDK 0.2.174 (previously 0.2.162). Since 0.2.162 only five Python PRs touch
src/. The other releases are bundled-CLI bumps and CI changes.get_session_messagesinclude_hook_eventsdocsdocs/options.mdSystemInitDataInitMessage#capabilitiesetc.ignoreViolationstypeHash[String, Array[String]]since before 1.0#1422: the tool calls a parallel batch's walk passed by
#157 (1.2.0) put back the off-chain results of parallel tool calls. It only looked for results of calls already on the chain. The conversation goes on from the result written last. When that result answers an earlier call than the batch's last, the
tool_useentries written after it are off theparentUuidpath, so both readers dropped those calls and their results. Python's four result orders give this onmain:Now every entry of an API message on the chain goes back right after that message's last entry on the chain, in timestamp order with file order on a tie, as in Python and TS. Then the results are re-attached as before. A result the CLI parented on a hook attachment is matched to its call by
tool_use_idwhen the same agent wrote both. Atool_use_idclaimed by two API messages is never used.Ruby-specific, on purpose:
get_subagent_messageson the single-branch walk.[Image: ...]note under a screenshot result). A branch that goes on through a meta entry is still caught (spec), and so is one that goes on through another result of the batch (fourth commit, from the Codex review:result_a → attachment → result_b → replyon a dropped branch had putresult_aback; a batch result now counts as going on once something goes on from it). The fourth commit changes nothing on the 7479 local transcripts (per-file diff against the third).Verification
bundle exec rake: 4371 examples, 0 failures; rubocop clean. 16 new examples inspec/unit/session_parallel_tool_results_spec.rb: Python's four orders, store-backed with a retried mirror batch, a batch that ends the transcript, paging, timestamp order, the streamed shape, a result under an attachment, a result under another result (and the same on a dropped branch), the meta note, rewind through a meta entry, an earlier attempt at the turn, and a subagent transcript. 13 fail againstmain(theabcorder, rewind-through-a-meta-entry and the dropped branch with one result under another already passed there; the last two pin that the narrowed guard still holds).The 43 are 32 calls still running when the session ended (no result in the file) and 11 whose result heads an off-chain branch with an assistant reply (a real dropped branch). The 1 is a transcript whose first entry is a result whose call is not in the file.
sig/is unchanged.Affected sessions return more messages than before, so
offset:/limit:pages over them shift (CHANGELOG).🤖 Generated with Claude Code
https://claude.ai/code/session_01PQPc2HryX1S85K3x1FqRfT
Need help on this PR? Tag
@codesmith-botwith what you need.