Skip to content

fix: route OpenAI-compatible gateways to the Chat Completions adapter - #80

Open
JeffC0628 wants to merge 1 commit into
CopilotKit:mainfrom
JeffC0628:fix/openai-compatible-chat-completions
Open

JeffC0628 wants to merge 1 commit into
CopilotKit:mainfrom
JeffC0628:fix/openai-compatible-chat-completions

Conversation

@JeffC0628

Copy link
Copy Markdown

What changed

DeepSeek (and any OpenAI-compatible endpoint that does not fully implement the Responses API tool loop) rejects the second /responses request with 400 No tool output found for tool call ... (request_id: ...) once the agent sends a tool result back, so every tool-using task fails with a RUN_ERROR.

This adds an opt-in OPENAI_CHAT_COMPLETIONS=true flag: when set, the openai provider is served by TanStack's openaiChatCompletions adapter (/v1/chat/completions) instead of the Responses-API openaiText adapter. The default keeps using the Responses API, so official OpenAI and existing gateway setups are untouched.

  • apps/server/src/engine/tanstack-agent.ts: choose openaiChatCompletions when OPENAI_CHAT_COMPLETIONS === "true".
  • .env.example: document the flag.
  • tests/helpers/model.ts: the Responses fixture now pins its wire format against a developer .env flag; adds a Chat Completions wire-format fixture.
  • tests/gateway-chat-completions.test.ts: regression tests for both wire formats.

Verification

  • End-to-end repro against DeepSeek (OPENAI_BASE_URL=https://api.deepseek.com, MODEL=openai/deepseek-chat): a tool-using task previously failed with 400 No tool output found for tool call ... (request_id: ...); with the flag set it completes the full tool loop (tool call → result → final reply) over /v1/chat/completions.
  • pnpm exec tsc --noEmit — pass.
  • pnpm --dir apps/mobile typecheck — pass.
  • pnpm build:server — pass.
  • pnpm test — full suite passes (208 tests, 0 failures), including the new gateway regression tests.
  • pnpm lint: on a Windows checkout biome reports repo-wide CRLF line-ending formatting (pre-existing, affects all files). The changed TS files pass biome after line-ending normalization; CI checks out LF (* text=auto in .gitattributes).

Integration limits

  • Not tested against live Anthropic / Gemini / other providers — those adapter paths are untouched.
  • Not run: build:web / build:ios / build:android — the change is server-side only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant