Repository navigation
refactor(ai): split completions transport into concept modules - #122122
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 12:04 PM ET / 16:04 UTC. ClawSweeper reviewWhat this changesThe PR divides OpenAI-compatible chat-completions request shaping and streamed-response handling into focused internal modules while retaining the existing transport facade and exports. Merge readinessKeep open. This is a useful, maintainer-owned refactor; inspection found the stable facade, routing, payload construction, replay, and stream decoding preserved rather than replaced. Priority: P3 Review scores
Verification
How this fits togetherThe AI transport converts normalized agent context into OpenAI-compatible completion requests and turns streamed provider events into assistant text, reasoning, usage, and tool calls. The change reorganizes those internal stages without adding a new public transport API. flowchart LR
A[Agent context and model] --> B[Completion parameters]
B --> C[Stable transport facade]
C --> D[OpenAI-compatible request]
D --> E[Stream and DSML decoding]
E --> F[Assistant output and tool calls]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +193, Tests +252, Other -5. Total +440 across 38 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the stable facade and internal concept split, then land only after exact-head validation confirms the moved provider payload and stream behavior. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors an existing transport rather than reporting a user failure; loopback request and stream tests cover the affected boundary. Is this the best way to solve the issue? Yes. Splitting behind the unchanged facade follows the established Responses transport pattern and keeps public exports stable while giving stream, replay, and payload logic clear owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 32e3bd3797f0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…law#122122) * refactor(ai): split completions transport into concept modules * refactor(ai): delete duplicated transport helpers * chore(lint): ratchet max-lines baseline after transport split * test(scripts): update prefix expansion expectation
What Problem This Solves
openai-completions-transport.tshad grown to roughly 2,100 lines and combined client lifecycle, stream decoding, DeepSeek DSML recovery, outbound parameter shaping, and reasoning replay policy in one module. That made concept ownership, focused tests, and the max-lines ratchet harder to maintain.Why This Change Was Made
This splits the transport behind its stable façade into concept-owned stream, DSML, params, replay, and Azure-host classification modules. The façade continues to export only
createOpenAICompletionsTransportStreamFnandbuildOpenAICompletionsParams; the package barrel is unchanged and all new leaf symbols remain package-private.Completion-owned tests now live beside the package concepts while residual Responses coverage keeps its existing agent-test filenames and CI ownership. The follow-up cleanup consolidates tool-history detection in
openai-completions-messages.ts, removes the test-global transport API and wrappers, and makes the Together parameter mutator void.User Impact
No behavior or configuration changes are intended. OpenAI-compatible completions payload shaping, stream event ordering, DSML recovery, reasoning replay, usage accounting, Azure query/header handling, and public exports remain unchanged.
Evidence
pnpm build: passed, including package declarations, runtime postbuild, Plugin SDK export verification, and Control UI build.node scripts/check-changed.mjs: passed all selected core, core-test, and tooling lanes locally after remote backends were unavailable (Blacksmith CLI absent; managed Crabbox broker login absent).pnpm plugin-sdk:surface:check: passed (152 public subpaths verified).pnpm lint:tmp:export-name-collisions: passed.pnpm check:wrapper-shadowing: passed.pnpm check:import-cycles: passed with 0 runtime value cycles.pnpm check:max-lines-ratchet: passed with 955 grandfathered suppressions.@openclaw/ai/transportsexport comparison: 77 before / 77 after; added 0, removed 0.