Repository navigation
fix(proxy): suppress duplicate side-effect tool calls - #586
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a337e6aa9
ℹ️ 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".
6a337e6 to
5911be5
Compare
|
Thanks @Komzpa -- the side-effect tool-call dedupe is exactly the right shape (per-response id cache, side-effect allowlist, P1 --
|
|
To use Codex here, create an environment for this repo. |
7beee93 to
df2d161
Compare
ef140e6 to
19cc805
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: beeb2d7fa6
ℹ️ 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".
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d9717421dd
ℹ️ 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".
|
@Komzpa second-round One new P1 from this round to address before merge — found at
Concretely, today the loop only resets Failure mode in production: in a mixed turn Suggested fix — reset the side-effect chain state whenever the current item is not a side-effect tool call: for index, item in enumerate(input_items):
if isinstance(item, dict) and replayed_input_segment_boundary(item):
first_call_id_by_key.clear()
last_side_effect_key = None
key = call_keys.get(index)
if key is None:
last_side_effect_key = None # <-- non-side-effect breaks the replay chain
continue
# ... existing side-effect logic( Regression to pin: def test_dedupe_replayed_side_effect_keeps_repeat_after_read_only_intermission():
"""side-effect A -> read-only R -> side-effect A (same args) must keep both A's."""
input_items = [
_function_call("call_a1", name="write_stdin", arguments=json.dumps({"chars": "hi"})),
_function_call_output("call_a1", output="ok"),
_function_call("call_r", name="read_file", arguments=json.dumps({"path": "/tmp/x"})),
_function_call_output("call_r", output="..."),
_function_call("call_a2", name="write_stdin", arguments=json.dumps({"chars": "hi"})),
_function_call_output("call_a2", output="ok"),
]
result, removed = dedupe_replayed_side_effect_input_items(input_items)
assert removed == 0
assert [item.get("call_id") for item in result if isinstance(item, dict)] == [
"call_a1", "call_a1", "call_r", "call_r", "call_a2", "call_a2",
](Adjust the Pair it with the existing After this lands I'll re-run |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d9717421dd
ℹ️ 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".
d971742 to
bdabc3e
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bdabc3e60b
ℹ️ 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".
9f989b9 to
de39ff8
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de39ff8f81
ℹ️ 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".
de39ff8 to
f6aa1c6
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0eaa54075d
ℹ️ 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".
| if _websocket_input_item_type(item) in {"function_call_output", "custom_tool_call_output"} | ||
| ), |
There was a problem hiding this comment.
Handle apply_patch replay items when trimming prior-response input
Extend the replay-prefix trimming logic to recognize apply_patch_call / apply_patch_call_output items; currently the scan at _trim_websocket_previous_response_input_items only treats function_call_output and custom_tool_call_output as output boundaries, so follow-up requests whose prior turn used apply_patch are left untrimmed and resend full prior assistant/tool history. In websocket continuity flows this can reintroduce duplicate side-effect calls or trigger avoidable missing_tool_output failures because stale tool-call items are forwarded instead of being trimmed to outputs.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f1fc948b2
ℹ️ 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".
| grouped_previous_response_request_states = _pop_matching_websocket_request_states( | ||
| pending_requests, | ||
| _all_pending_websocket_followup_requests(pending_requests), | ||
| ) |
There was a problem hiding this comment.
Scope missing-tool-output fallback to matching requests
When missing_tool_output cannot be matched by response_id/hint, this fallback pops all pending follow-up requests, not just the affected continuity chain. If a bridge/socket has multiple queued requests with different previous_response_id values, one upstream continuity error will incorrectly fail unrelated requests as stream_incomplete, creating user-visible cross-request blast radius.
Useful? React with 👍 / 👎.
| # Same-response replays have shown distinct call_ids for byte-identical shell/edit requests. | ||
| # For local side-effect tools, running the same payload twice is worse than dropping a duplicate-looking call_id. | ||
| dedupe_call_id = None if is_side_effect_tool_call else call_id | ||
| if is_side_effect_tool_call: |
There was a problem hiding this comment.
Preserve call_id in side-effect duplicate detection
This change intentionally discards call_id for side-effect dedupe, so two distinct tool calls with identical arguments in the same response collapse to one key and the later call is suppressed. Since Responses streams can legitimately emit multiple calls for the same tool in one turn, argument-only dedupe can drop valid operations and force a synthetic terminal failure even when no replay occurred.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a7e33095e
ℹ️ 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".
| if mark_duplicate_tool_call_downstream_event( | ||
| payload, | ||
| seen_tool_call_keys=session.seen_tool_call_keys, | ||
| response_id=tool_call_response_id_from_payload(payload) or matched_request_state.request_id, | ||
| scope_side_effects_by_response_id=False, | ||
| ): |
There was a problem hiding this comment.
Scope HTTP-bridge tool-call dedupe to a response
Using scope_side_effects_by_response_id=False with the session-level cache causes side-effect tool calls from later responses to be treated as duplicates of earlier turns on the same HTTP bridge session. This is reproducible when one turn ends after a side-effect response.output_item.done (no non-side-effect item clears the cache) and the next turn legitimately issues the same tool operation: the second call is suppressed and the turn can be rewritten to stream_incomplete. That violates per-response isolation and breaks normal repeated tool workflows.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Archive changes shipped in v1.18.0 and v1.18.1 per AGENTS.md "release 이후 archive" workflow. All 12 changes verified shipped in production at 10.0.0.113 (image 1.18.1, sha256:0431a474432d). 1.18.0 (9 changes): - deactivate-on-token-expired (#600) - drop-unknown-message-fields (#637) - mask-single-http-previous-response-miss (#516) - normalize-v1-responses-openai-sdk-stream (#639) - start-device-oauth-polling (#635) [delta header fixed: MODIFIED -> ADDED] - support-prolite-plan-capacity (#558) [delta header fixed: MODIFIED -> ADDED] - treat-upstream-overloaded-as-retryable (#601) - validate-password-length (#598) - validate-strict-function-tool-schema (#658) 1.18.1 (3 changes): - harden-long-codex-websocket-turns (#586) - suppress-duplicate-side-effect-tool-calls (#586) - hotfix-db-pool-pre-ping-and-firewall-cache-ttl (#679) Specs updated: 9 capabilities (admin-auth, api-firewall, chat-completions-compat, chat-completions-extensions, database-backends, frontend-architecture, responses-api-compat, usage-refresh-policy). openspec validate --specs: 19/19 passed. Co-authored-by: Hermes Agent <[email protected]>
* fix(proxy): relax Codex long-turn timeouts * fix(proxy): penalize websocket upstream drops * docs(openspec): document long Codex websocket turns * fix(proxy): avoid penalizing rejected websocket input * fix(proxy): treat upstream websocket errors as terminal * fix(proxy): keep downstream streams alive during upstream stalls * fix(types): satisfy stream keepalive checks * fix(proxy): bound websocket stream idle stalls * fix(proxy): preserve stream startup errors * fix(proxy): keep stream startup failover * fix(proxy): keep websocket fail-closed terminal * fix(proxy): preserve bridge startup errors * fix(proxy): raise default stream idle timeout * fix(proxy): avoid continuity helper merge conflicts * fix(proxy): place trim logging after bridge state * fix(proxy): address long-turn review blockers * fix(proxy): omit turn state on bridge startup errors * fix(proxy): keep stream error frames best effort * fix(proxy): suppress duplicate side-effect tool calls * fix(proxy): mask missing tool output continuity errors * fix(proxy): fail closed suppressed stream tool calls * fix(proxy): keep read-only parallel tool calls * fix(proxy): trim overlapping parallel tool replays * fix(proxy): propagate trimmed parallel tool events * fix(proxy): retire unsafe bridge after tool dedupe * fix(proxy): preserve malformed tool input errors * fix(proxy): dedupe replayed side-effect input history * test(proxy): expect side-effect replay suppression * fix(proxy): keep bridge tool dedupe across reconnects * fix(proxy): dedupe direct side-effect tool replays * fix(proxy): narrow side-effect replay dedupe * fix(proxy): fail closed unmatched tool-output gaps * fix(proxy): finish side-effect replay review fixes * fix(proxy): make duplicate tool-call guard stack-friendly * fix(proxy): avoid reservation-touch merge conflicts * fix(proxy): leave reservation touch insertion room * fix(proxy): keep write waits distinct in dedupe * fix(proxy): narrow missing tool replay matching * fix(proxy): tighten side-effect replay dedupe * style(proxy): format dedupe helpers * test(proxy): document cross-response replay suppression * fix(proxy): satisfy typed replay suppression test * fix(proxy): retain side-effect dedupe replay window * fix(proxy): make replay suppression stack-compatible * test(proxy): align previous-response reconnect expectations * fix(proxy): drain typeless upstream errors after tool-output matching * fix(proxy): keep websocket keepalives on real responses * fix(proxy): avoid duplicate bridge health penalties * fix(proxy): leave bridge quota penalties to replay branch * fix(proxy): honor prehandled stream health errors * fix(proxy): normalize typeless websocket errors * fix(proxy): trim apply-patch replay prefixes * fix(proxy): scope continuity and tool replay dedupe * fix(proxy): preserve distinct tool call ids * fix(proxy): scope bridge tool dedupe per request * fix(proxy): isolate bridge tool dedupe state
…u06#682) Archive changes shipped in v1.18.0 and v1.18.1 per AGENTS.md "release 이후 archive" workflow. All 12 changes verified shipped in production at 10.0.0.113 (image 1.18.1, sha256:0431a474432d). 1.18.0 (9 changes): - deactivate-on-token-expired (Soju06#600) - drop-unknown-message-fields (Soju06#637) - mask-single-http-previous-response-miss (Soju06#516) - normalize-v1-responses-openai-sdk-stream (Soju06#639) - start-device-oauth-polling (Soju06#635) [delta header fixed: MODIFIED -> ADDED] - support-prolite-plan-capacity (Soju06#558) [delta header fixed: MODIFIED -> ADDED] - treat-upstream-overloaded-as-retryable (Soju06#601) - validate-password-length (Soju06#598) - validate-strict-function-tool-schema (Soju06#658) 1.18.1 (3 changes): - harden-long-codex-websocket-turns (Soju06#586) - suppress-duplicate-side-effect-tool-calls (Soju06#586) - hotfix-db-pool-pre-ping-and-firewall-cache-ttl (Soju06#679) Specs updated: 9 capabilities (admin-auth, api-firewall, chat-completions-compat, chat-completions-extensions, database-backends, frontend-architecture, responses-api-compat, usage-refresh-policy). openspec validate --specs: 19/19 passed. Co-authored-by: Hermes Agent <[email protected]>
Draft split from #555.
Purpose
call_id.response_idso separate turns are not suppressed as duplicates.multi_tool_use.parallelbefore forwarding the batch to the client.Validation
main.ruff format --check,ruff check, andty checkon touched backend/test files passed locally.172f032bb306a712119a29ee157a0ce5d6fd6060.@codex reviewcompleted for172f032bb306a712119a29ee157a0ce5d6fd6060; no inline review comments were reported.Relationship