Skip to content

refactor(ai): unify Responses transport factories - #114357

Merged
steipete merged 2 commits into
mainfrom
codex/codex-r2-transport
Jul 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/codex-r2-transport

Conversation

@steipete

@steipete steipete commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

The AI package maintained parallel OpenAI Responses transport factories whose setup and execution behavior had converged. Keeping two implementations increased the chance of retry, stream-observation, or request-option behavior drifting between otherwise signature-compatible entry points.

Why This Change Was Made

This introduces one createResponsesTransportExecutor implementation and leaves the existing public wrappers thin and signature-compatible. The executor preserves the current differences between OpenAI and Azure: output API labeling, deployment resolution, streaming request hints, response creation, pricing, and Azure's default first-event timeout. The newer stream-observation and reasoning-replay metadata behavior from main is shared by both paths.

User Impact

No intended user-visible behavior change. Both Responses transport entry points retain their signatures and behavior with 76 fewer lines of duplicate implementation on the current layout.

Evidence

  • Exact head: 8199fbbfebf969218e7d92f57707c00591508e6e.
  • Current diff: 66 insertions, 142 deletions (net -76 LOC).
  • Original transport proof: 160/160 tests passed; moved provider proof: 140/140 passed.
  • Post-conflict focused proof: 23/23 tests passed across transport parity, Azure Responses, and OpenAI Responses suites.
  • Exact-head hosted CI passed: run 30241490726.
  • Live OpenAI Responses proof passed 4/4 real-provider tests on the exact head using gpt-5.6-luna.
  • Azure live proof is still blocked because no approved Azure credential, endpoint, and deployment configuration is available in the validation environment. This PR must remain parked unless an AI-area maintainer explicitly accepts that gap or supplies an approved proof route.
  • Original node scripts/check-changed.mjs passed on Blacksmith Testbox.
  • Fresh post-conflict autoreview was clean with no accepted/actionable findings (confidence 0.89); the formatting-only follow-up rereview was clean at confidence 1.0. TruffleHog was clean.
  • Codex dependency contract inspected directly at codex-rs/codex-api/src/sse/responses.rs:34 and codex-rs/core/src/client.rs:1940 in openai/codex.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 27, 2026
@steipete
steipete force-pushed the codex/codex-r2-transport branch from 8400182 to 642b35f Compare July 27, 2026 05:59
@steipete steipete self-assigned this Jul 27, 2026
@steipete
steipete marked this pull request as ready for review July 27, 2026 05:59
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 2:24 AM ET / 06:24 UTC.

ClawSweeper review

What this changes

The PR replaces separate OpenAI and Azure Responses streaming factory bodies with one configurable executor while retaining the two public wrapper entry points.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 5 items remain

Keep open. This is an active, maintainer-labeled AI transport refactor; the supplied evidence shows exact-head OpenAI live coverage, but the shared executor also changes Azure execution and no approved Azure live proof or explicit AI-area acceptance of that gap is established here.

Priority: P3
Reviewed head: 8199fbbfebf969218e7d92f57707c00591508e6e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The refactor has focused validation and OpenAI live evidence, but the unproved Azure runtime path remains a merge gate.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The PR body provides exact-head live OpenAI output, but no real Azure Responses run for the shared execution path; add redacted Azure evidence or obtain explicit AI-area acceptance of that gap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR body provides exact-head live OpenAI output, but no real Azure Responses run for the shared execution path; add redacted Azure evidence or obtain explicit AI-area acceptance of that gap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items PR scope: The supplied pull-request patch changes only the Responses transport implementation, introducing a configurable shared executor while retaining provider-specific wrapper configuration.
Exact-head OpenAI proof: The PR body reports 4/4 live OpenAI Responses tests passing on the exact head, plus focused transport/provider test coverage and hosted CI.
Azure proof gap: The PR body explicitly says Azure live validation is blocked by the lack of approved Azure credentials, endpoint, and deployment configuration, and asks that the branch remain parked without explicit AI-area acceptance.
Findings None None.
Security None None.

How this fits together

OpenClaw's AI transport layer turns a selected model, conversation context, and provider-specific options into a streamed assistant response. The OpenAI and Azure Responses entry points share most stream processing but retain different client construction, deployment, pricing, and timeout behavior.

flowchart LR
  A[Selected model and context] --> B[OpenAI or Azure wrapper]
  B --> C[Shared Responses executor]
  C --> D[Provider-specific client and request]
  D --> E[Responses event stream]
  E --> F[Assistant message and usage output]
Loading

Decision needed

Question Recommendation
Can an AI-area owner accept the shared Responses refactor with exact-head OpenAI live proof and focused Azure tests, despite no approved Azure live-provider run? Require Azure live proof: Provide an approved Azure endpoint, deployment, and redacted after-fix runtime transcript before merging.

Why: The patch intentionally centralizes execution used by Azure, but the available validation environment cannot exercise an Azure deployment; accepting that coverage boundary is a release-risk judgment rather than a mechanical code change.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR body provides exact-head live OpenAI output, but no real Azure Responses run for the shared execution path; add redacted Azure evidence or obtain explicit AI-area acceptance of that gap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P2) - The shared executor changes the Azure Responses path as well as OpenAI; unit and focused provider tests do not replace a real Azure deployment/credential run for timeout, deployment resolution, and request construction.
  • Resolve merge risk (P1) - The PR carries the protected maintainer label, so explicit maintainer handling is required before cleanup or merge automation.
  • Complete next step (P2) - An AI-area maintainer must decide whether the missing Azure live-provider proof is acceptable before this protected-label PR can proceed.
Agent review details

Security

None.

PR surface

Source -76. Total -76 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 66 142 -76
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 66 142 -76

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: packages/ai/src/transports/openai-responses-client.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Add Azure runtime evidence (recommended)
    Run the Azure Responses path against an approved deployment and attach a redacted terminal transcript showing the after-refactor result.
  2. Explicitly accept the Azure gap
    An AI-area owner may document that focused Azure tests and the OpenAI live run are adequate for this internal refactor.

Technical review

Best possible solution:

Keep the two public wrappers and land the consolidation only after a redacted Azure real-provider transcript is added or an AI-area owner explicitly accepts the bounded Azure proof gap.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR is a refactor rather than a report of broken behavior; the relevant question is whether both existing provider paths preserve their runtime contracts.

Is this the best way to solve the issue?

Unclear: consolidating converged execution is a maintainable direction, but the best-fix judgment remains incomplete until Azure-specific runtime behavior is demonstrated or an AI-area owner accepts the missing live proof.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 604f37920310.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P3: This is a behavior-neutral internal refactor with a bounded provider-validation question rather than a reported user regression.
  • merge-risk: 🚨 auth-provider: One shared executor now serves Azure and OpenAI Responses paths, so an unobserved provider-specific request or timeout difference could affect configured provider behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body provides exact-head live OpenAI output, but no real Azure Responses run for the shared execution path; add redacted Azure evidence or obtain explicit AI-area acceptance of that gap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • steipete: Authored both commits in this PR and supplied the transport-specific validation context; no broader current-main ownership history could be verified in this read-only review. (role: recent area contributor; confidence: low; commits: 642b35f7cb2a, 8199fbbfebf9; files: packages/ai/src/transports/openai-responses-client.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted Azure Responses live run on the exact head, including an approved deployment result.
  • If Azure credentials cannot be supplied, obtain explicit AI-area owner acceptance of the scoped proof gap.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-27T06:07:26.208Z sha 8199fbb :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper rank-up move — explicit owner decision:

Peter Steinberger (@steipete), repository owner and AI-area maintainer, accepts landing this exact head (8199fbbfebf969218e7d92f57707c00591508e6e) without a separate Azure live-provider run.

The accepted proof boundary is narrow: the Azure factory remains a signature-identical thin wrapper over the same shared executor exercised by the 4/4 exact-head live OpenAI Responses tests already documented on this PR. The provider-specific Azure construction, deployment resolution, request options, pricing, and first-event timeout remain passed into that executor through the existing wrapper configuration and are covered by the focused Azure/provider tests.

This explicitly satisfies ClawSweeper's documented alternative rank-up move, "obtain explicit AI-area owner acceptance of the scoped proof gap." Exact-head hosted CI is green in run 30241490726.

@steipete
steipete merged commit 9588a10 into main Jul 27, 2026
134 of 138 checks passed
@steipete
steipete deleted the codex/codex-r2-transport branch July 27, 2026 16:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to IWhatsskill/openclaw that referenced this pull request Jul 27, 2026
* origin/main:
  refactor(ai): unify Responses transport factories (openclaw#114357)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 28, 2026
* refactor(ai): unify Responses transport factories

* style(ai): format Responses transport executor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant