Repository navigation
Conversation
PR SummaryIntroduces an OpenAI-compatible Chat Completions endpoint on the Gateway (same port,
Written by Cursor Bugbot for commit 8ecb0a8. This will update automatically on new commits. Configure here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97bd183c1a
ℹ️ 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".
| req.on("close", () => { | ||
| closed = true; | ||
| unsubscribe(); | ||
| }); |
There was a problem hiding this comment.
Abort agent runs when HTTP client disconnects
The streaming handler only marks the request as closed and unsubscribes from events on req.close, but it never cancels the in-flight agentCommand that was started for the same request. If a client drops the SSE connection mid-run (network blip, user cancels, load balancer timeout), the agent continues executing tools and generating events anyway, wasting resources and potentially holding session locks longer than necessary. Other gateway chat paths pass an AbortSignal to agentCommand and cancel on disconnect; you should mirror that here by wiring an AbortController to the request close and passing abortSignal into agentCommand.
Useful? React with 👍 / 👎.
| } | ||
| if (role === "user") { | ||
| lastUser = content; | ||
| } |
There was a problem hiding this comment.
Multi-turn conversation history discarded in prompt building
Medium Severity
The buildAgentPrompt function only captures the last user message (via lastUser = content which overwrites previous user messages) and completely ignores assistant messages. When clients send multi-turn conversation history as expected in the OpenAI Chat Completions API, all prior context except system prompts and the final user message is silently discarded. This breaks conversational continuity for clients expecting standard OpenAI-compatible behavior.
| .map((p) => (typeof p.text === "string" ? p.text : "")) | ||
| .filter(Boolean) | ||
| .join("\n\n") | ||
| : "No response from Clawdbot."; |
There was a problem hiding this comment.
Empty response when payloads contain only empty text
Low Severity
The fallback message "No response from Clawdbot." is bypassed when payloads is a non-empty array but all payload texts are empty strings. The condition Array.isArray(payloads) && payloads.length > 0 checks if payloads exist, but after .filter(Boolean) removes empty strings, the resulting content becomes "". For example, if payloads = [{ text: "" }], the condition is true, but the processed result is an empty string instead of the intended fallback message. The same pattern appears in both the non-streaming and streaming fallback code paths.
Additional Locations (1)
|
Landed on \ via:\n- dafa8a2 feat(gateway): add OpenAI-compatible HTTP endpoint\n- 6d01d70 docs(gateway): add OpenAI HTTP API to docs nav\n- 72d4317 fix(docs): dedupe /sandbox redirects\n- 6546a1a feat(gateway): allow agent via model\n- 0d00d6d style(gateway): format openai-http\n- 67fdee6 docs(changelog): note OpenAI HTTP endpoint\n- d45c27e chore(protocol): regenerate GatewayModels.swift (fix protocol:check)\n\nNot landed: 96a6635 fix(pnpm): sync patchedDependencies (conflicted / not needed after upstream moved).\n |
|
Correction: that was |
Adds an OpenAI-compatible Chat Completions HTTP endpoint on the gateway (same port), including SSE streaming.\n\n- New handler: src/gateway/openai-http.ts\n- Wired into HTTP server: src/gateway/server-http.ts\n- Docs: docs/gateway/openai-http-api.md (+ index link)\n- E2E tests hitting the real HTTP endpoint: src/gateway/openai-http.e2e.test.ts\n\nAuth: uses existing gateway auth via Authorization: Bearer <token/password>.\nAgent targeting: x-clawdbot-agent-id header (default main); optional x-clawdbot-session-key override; OpenAI user enables stable session key.