Skip to content

fix(proxy): recover compact bridge continuations - #1727

Closed
Komzpa wants to merge 3 commits into
Soju06:mainfrom
Komzpa:fix/agent-wait-tool-routing-20260813
Closed

fix(proxy): recover compact bridge continuations#1727
Komzpa wants to merge 3 commits into
Soju06:mainfrom
Komzpa:fix/agent-wait-tool-routing-20260813

Conversation

@Komzpa

@Komzpa Komzpa commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • preserve replayed tool-call namespace metadata on standard/live Responses egress, including WebSocket response.create and configured Responses model-source forwarding
  • keep compact-specific namespace stripping limited to the compact serializer
  • preserve historical agent-control wait/spawn outputs during response.create slimming, including already-namespace-stripped legacy history
  • update the replay namespace OpenSpec change to make the live-vs-compact boundary explicit

Validation

  • uv run pytest tests/unit/test_openai_requests.py tests/unit/test_proxy_utils.py tests/integration/test_api_keys_api.py tests/integration/test_proxy_websocket_responses.py -q
  • git diff --check
  • PR scope gate passed for origin/main...HEAD; changed files are limited to proxy/request code, Responses compatibility specs, and focused tests.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8d512c479

ℹ️ 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".

Comment thread app/modules/proxy/_service/response_create.py Outdated
@Komzpa
Komzpa force-pushed the fix/agent-wait-tool-routing-20260813 branch from 7c20e6c to ff94b58 Compare August 13, 2026 18:29
@Komzpa Komzpa changed the title fix(proxy): preserve agent wait outputs during slimming fix(proxy): preserve replayed tool namespaces Aug 13, 2026
@Komzpa Komzpa added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: needs work [@codex review] raised an issue labels Aug 13, 2026
@Komzpa
Komzpa force-pushed the fix/agent-wait-tool-routing-20260813 branch 4 times, most recently from c6fb862 to efdffb9 Compare August 14, 2026 05:47
@Komzpa Komzpa changed the title fix(proxy): preserve replayed tool namespaces fix(proxy): recover compact bridge continuations Aug 14, 2026
@Komzpa

Komzpa commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efdffb9be8

ℹ️ 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".

Comment on lines +217 to 218
protected_tool_output_call_ids = _protected_agent_control_tool_call_ids(payload.input)
upstream_payload = dict(payload.to_payload())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve namespaces on standard response.create egress

The fresh pre-serialization capture here addresses the earlier slimming-set comment, but upstream_payload is still built immediately afterward with ResponsesRequest.to_payload(), which invokes _strip_unsupported_fields() with replayed-namespace stripping enabled. Consequently, standard HTTP-bridge and WebSocket replays containing collaboration or multi_agent_v1 calls still reach upstream without the routing namespace promised by the newly edited live-egress contract; only the model-source path was changed to avoid this serializer. Use the namespace-preserving serializer on every standard live path and assert the actual HTTP and WebSocket payloads.

AGENTS.md reference: AGENTS.md:L129-L132

Useful? React with 👍 / 👎.

Comment on lines +97 to +101
is_agent_control = (
isinstance(namespace, str)
and namespace in _AGENT_CONTROL_TOOL_NAMESPACES
or isinstance(name, str)
and name in _AGENT_CONTROL_TOOL_NAMES

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Let explicit non-agent namespaces override legacy name matching

When a non-agent namespaced tool happens to use a common name such as database.send_input or workflow.wait_agent, this or classifies it as agent control solely by name. Its oversized historical output is then exempted from slimming, so a request whose excess size comes from that output remains above the wire limit and is rejected instead of receiving the normal omission notice. Restrict the name-only fallback to calls with no usable namespace so an explicit unrelated namespace takes precedence.

Useful? React with 👍 / 👎.

Comment on lines +3 to +5
### Requirement: Replayed tool-call namespace metadata survives live Responses egress

For standard and compact Responses requests, the proxy MUST omit `namespace` from every replayed `input` item whose `type` is `function_call`, `custom_tool_call`, or `apply_patch_call` before forwarding the request upstream. The proxy MUST preserve all other fields on that item, MUST retain the original namespace metadata for local call-identity and replay-deduplication processing, and MUST NOT alter client-provided top-level tool entries as part of this normalization.
For standard live Responses requests, including WebSocket `response.create` and configured Responses model-source egress, the proxy MUST preserve `namespace` on replayed `input` items whose `type` is `function_call`, `custom_tool_call`, or `apply_patch_call`. Tool namespaces are part of the live tool-routing identity. Compact Responses egress MAY omit those namespaces only as part of the compact-specific upstream compatibility serializer. The proxy MUST preserve all other fields on each tool-call item and MUST NOT alter client-provided top-level tool entries as part of this normalization.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Sync the namespace contract into the main specification

This archived delta now requires standard live Responses egress to preserve replayed namespaces, but the normative main spec still contains the opposite requirement and scenarios at openspec/specs/responses-api-compat/spec.md:4357-4383, saying that standard, WebSocket, and model-source egress must omit them. Because the main capability spec is the repository's source of truth, leaving only the archived artifact updated documents the wrong compatibility contract and invites the stripping behavior to be restored; replace the obsolete main requirement and scenarios as part of this change.

AGENTS.md reference: AGENTS.md:L24-L28

Useful? React with 👍 / 👎.


Flat legacy side-effect calls MAY continue to use argument-based replay identity so reconnects that change only a call ID do not repeat shell, patch, or terminal side effects.

Historical response.create slimming MUST preserve outputs for namespaced agent-control calls, including `collaboration` and `multi_agent_v1` calls, even when those outputs are large. Such outputs carry the completed spawn/wait state needed by the next model turn and MUST NOT be replaced with a generic historical tool-output omission notice. Unrelated historical tool outputs MAY still be slimmed under the normal payload-budget policy.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Protect agent outputs in the direct WebSocket slimmer

This new requirement is not applied to the separate direct-upstream WebSocket path: app/core/clients/proxy.py:1958 calls its own _prepare_websocket_response_create_payload(), whose private slimmer at lines 2242-2265 still replaces every oversized historical tool output without identifying agent-control calls. Therefore, when the regular Responses route selects transport == "websocket" rather than the HTTP bridge, a large completed spawn/wait output is still replaced by the omission notice and the next model turn loses the agent state. Route that product path through the same protection logic and add a regression test through the regular Responses endpoint.

AGENTS.md reference: AGENTS.md:L125-L128

Useful? React with 👍 / 👎.

@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Aug 14, 2026
@Komzpa
Komzpa force-pushed the fix/agent-wait-tool-routing-20260813 branch from efdffb9 to 680a73f Compare August 14, 2026 09:26
@github-actions github-actions Bot added the db migration PR changes Alembic database migrations; maintainer must coordinate merge order label Aug 14, 2026
@Komzpa
Komzpa force-pushed the fix/agent-wait-tool-routing-20260813 branch from 936be38 to 5878e74 Compare August 14, 2026 15:58
@Komzpa

Komzpa commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5878e74529

ℹ️ 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".

@@ -0,0 +1,22 @@
## ADDED Requirements

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add the required proposal for the ownerless-claim change

This proxy/session behavior change adds only tasks.md and a delta spec under fix-ownerless-bridge-claim; repository-wide inspection of that change folder finds no proposal.md. This leaves the change without the required proposal artifact and fails the repository's hard OpenSpec merge gate, so add the proposal before treating the checked-off tasks as ready.

AGENTS.md reference: AGENTS.md:L92-L98

Useful? React with 👍 / 👎.

Comment on lines +1617 to +1618
if len(visible_unresolved_followups) == 1:
return visible_unresolved_followups

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Exercise visible-vs-draining matching through the HTTP bridge

The only new coverage for this branch calls _matching_websocket_request_states_for_previous_response_error() directly; inspection of the changed HTTP bridge integration tests finds no route-level case with one live follow-up and one unresolved draining request. Because this selection controls which request is popped, settled, and receives an anonymous previous_response_not_found, a wiring regression could still terminate the wrong continuation; add a regression through the actual Responses HTTP bridge path.

AGENTS.md reference: AGENTS.md:L125-L128

Useful? React with 👍 / 👎.

@Komzpa Komzpa added the needs rebase Needs rebase or conflict repair against current main label Aug 14, 2026
@Komzpa
Komzpa force-pushed the fix/agent-wait-tool-routing-20260813 branch from 5878e74 to 074ac69 Compare August 14, 2026 18:33
@Komzpa

Komzpa commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

Folded into #1730: post-compaction continuation and namespace preservation join the quarantine replay carrier as one post-compaction continuation PR; series replayed onto a clean base with authorship preserved.

@Komzpa Komzpa closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 codex: needs work [@codex review] raised an issue db migration PR changes Alembic database migrations; maintainer must coordinate merge order needs rebase Needs rebase or conflict repair against current main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant