Repository navigation
refactor(ai): share provider transport request orchestration - #162491
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 4:24 AM ET / 08:24 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR shares Anthropic request preparation and OpenAI Chat Completions request lifecycles while retaining each public route’s existing defaults and stream behavior. Merge readiness✅ Ready for maintainer review The refactor remains useful: current main still contains parallel request orchestration. No concrete introduced correctness or security defect was found, and the prior review has no outstanding findings. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s AI package converts conversation history, model settings, and caller hooks into provider requests. These provider adapters and managed transports return streaming assistant events to the agent runtime. flowchart TD
A[Conversation and model settings] --> B[Direct provider route]
A --> C[Managed transport route]
B --> D[Shared request orchestration]
C --> D
D --> E[Provider HTTP or SDK client]
E --> F[Provider stream reducer]
F --> G[Assistant events]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -160, Other 0. Total -160 across 7 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one request lifecycle per provider family, with explicit route profiles preserving existing client, payload, cancellation, and event contracts. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR consolidates existing orchestration rather than reporting a failing user flow; no runtime reproduction was attempted. Is this the best way to solve the issue? Yes: sharing orchestration while retaining explicit route profiles removes competing lifecycle code without replacing the routes’ distinct contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 92457bebe2e1. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…w#162491) Share Anthropic request assembly and post-hook request contracts, and run direct and managed OpenAI Completions through one request lifecycle. Preserve public exports, SDK injection, authentication, caching, refusal buffering, cancellation and event ordering. Remove 160 net production lines. Validated with provider/transport and Vertex boundary tests, changed checks, independent review and both import-cycle checks.
What Problem This Solves
Anthropic and OpenAI Completions keep parallel request orchestration in their public provider and managed transport routes, making shared policy fixes easy to apply inconsistently.
User Impact
No intended behavior change. Both public routes remain, including injected Anthropic SDK clients used by Vertex. Authentication, payload hooks, cache markers, compaction replay, refusal buffering, cancellation and event ordering retain their existing profiles.
Why This Change Was Made
Anthropic now assembles requests and applies post-hook request/beta contracts through its existing message owner. Completions now has one request, response acceptance, first-event deadline, error and disposal lifecycle, with a private adapter for direct-route block endings. Existing public transport exports remain explicit. Distinct SDK/fetch framing and provider-specific policies remain at their owners.
The measured reduction is 160 production lines across six files; tests are unchanged. The remaining differences preserve distinct public-route contracts.
Evidence
tbx_01m3tzt14pmrnx42kbjtkke840(allocation run); source-capsule preparation did not reach remote execution after over 20 minutes. The owned invocation settled interrupted, the lease was stopped, and tests used the authorized serial local fallback atnice -n 15.Coverage of production owners over 200 lines
Scope: candidate 8 Anthropic and OpenAI Completions provider/transport orchestration and their protocol owners. Baseline 3b8ed7c; production files over 200 lines, sorted by baseline size.
Also inspected registered entry points, public package/barrel exports, Vertex SDK injection, transport options, host and transcript transformations, refusal/fallback helpers and matching boundary tests. No SDK surface, schema, config or protocol change. Six production files changed: 160 net lines removed; no test changes.