Skip to content

Keep intercepted tool results with their issuing turn - #3209

Open
xeophon wants to merge 1 commit into
codex/3205-claude-replayfrom
codex/3205-tool-issuers
Open

xeophon wants to merge 1 commit into
codex/3205-claude-replayfrom
codex/3205-tool-issuers

Conversation

@xeophon

@xeophon xeophon commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Associate intercepted tool results with their sampled assistant node and call ID. A gate with known ancestry uses that branch directly. A wire receipt can use its replayed history to identify a unique issuer. If two samples share that history and ID, the server reports ambiguity, even when the follow-up advertises a different tool catalog. An unrecognized call outside the sampled graph keeps its conversation-prefix key. The regression covers switching to a sibling’s catalog, switching to an unknown catalog, and resolving the same receipt with known ancestry.

Local unit suite on this commit reported 299 passed, 19 skipped. Full-stack CI before review fixes

Layer 2 of 13. Builds on #3208. Stack index

Note

Key tool results to issuing turn in RolloutSession replay handling

  • Tool-result keys in session.py now identify sampled tool calls by physical node ID plus call ID, instead of only a replay-prefix string. Replay-prefix aliases resolve to the sole sampled issuing node, or raise HarnessError when multiple issuers match.
  • gate_tool_calls, decide_tool, pin_tool_results, and rewrite_request all pass the branch's physical ancestry, root node's tool catalog, and per-node wire dialect into request rewriting and key derivation.
  • Renames the message-key helper to graph.replay_message_hash and extracts graph.path_node_ids in graph.py; the returned message sequence is unchanged.
  • The InterceptionServer model-response handler now passes the active dialect name to gate_tool_calls.
  • Adds a regression test in test_agent.py covering tool-result association across assistant replays, catalog changes, branches, ambiguous-issuer errors, and explicit-path resolution.
  • Behavioral Change: a replayed tool result that maps to multiple sampled issuing turns now raises HarnessError instead of silently attaching to an arbitrary turn.

Macroscope summarized 23e57cb.


Note

Medium Risk
Changes tool-result identity and request rewriting on every intercepted turn; mis-keying would corrupt transcripts, though ambiguity now fails fast and a regression test covers the branching cases.

Overview
Reworks how intercepted tool results are keyed and replayed so each call keeps the rewrite from the sampled assistant node that issued it, not a shared conversation-prefix hash.

RolloutSession now keys tool_decisions, pinned_tool_results, and gated_tools by (issuing node id, call id) (with prefix-based aliases for harness-only calls). tool_result_keys, pin_tool_results, and rewrite_request take dialect and an optional known_path so message matching uses replay_message_hash and sampled nodes populate tool_issuers. When the same replayed call ID could map to more than one issuer, the session raises HarnessError: Ambiguous issuing turn instead of picking one silently. gate_tool_calls records per-node dialect, builds probes from path_node_ids and the root node's tool catalog, and passes dialect/path into rewrites; decide_tool aligns with node-scoped keys.

graph exposes replay_message_hash (renamed from private _message_key) and path_node_ids; path is implemented via node ids. The interception server passes dialect.name into gate_tool_calls.

Adds test_each_sample_keeps_its_tool_result_across_assistant_replays covering sibling samples that reuse a call ID, catalog changes, follow-up gating, ambiguity errors, and explicit known_path pinning.

Reviewed by Cursor Bugbot for commit 23e57cb. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread verifiers/v1/session.py Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cdf4ed1. Configure here.

Comment thread verifiers/v1/session.py Resolved
@macroscopeapp

macroscopeapp Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 23e57cb

Macroscope's review found this PR approvable — Intercepted tool results now stay associated with their issuing sampled turn across replays and tool-catalog changes. Ambiguous associations fail explicitly, while existing tool-gate enforcement remains in place.

You can add or adjust custom eligibility rules. Learn more.

@xeophon
xeophon force-pushed the codex/3205-tool-issuers branch from cdf4ed1 to 23e57cb Compare November 19, 2026 01:30

This branch has not been deployed

No deployments
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