29 Commits
Author SHA1 Message Date
Tam Nhu Tran bb9d23ad6a fix(proxy): route Anthropic passthrough by upstream profile 2026-06-14 11:19:58 -04:00
Sanskar Singh b98b0df084 fix(proxy): add Anthropic passthrough mode for coding-agent-only endpoints
Some providers (e.g. Kimi, Anthropic-API mirrors) reject OpenAI-format
chat-completions requests and/or only accept requests from a recognized
coding-agent User-Agent (e.g. Claude Code, Roo Code, Kilo Code). The
OpenAI-compat proxy previously translated every profile's request to
OpenAI format and overwrote the User-Agent with a fixed sentinel,
which made these providers unreachable.

This change adds an opt-in Anthropic passthrough mode:

- New CCS_OPENAI_PROXY_PASSTHROUGH=1 env var on a profile opts it in.
- The base URL is auto-detected as Anthropic-style for known hosts
  (api.kimi.com, api.minimax.com, api.anthropic.com) or any base URL
  ending in /v1.
- In passthrough mode the proxy forwards the incoming Anthropic body
  verbatim to the upstream /v1/messages endpoint, preserving the
  original User-Agent (or x-stainless-user-agent) so coding-agent
  provider checks pass.
- The Anthropic-format response is streamed back unchanged.

Adds:
- isAnthropicPassthroughProfile() + passthrough option on
  resolveOpenAIChatCompletionsUrl/resolveOpenAIModelsUrl
- CCS_OPENAI_PROXY_PASSTHROUGH env var on OpenAICompatProfileConfig
- readRawBody() helper for the passthrough path
- Preserved User-Agent (or x-stainless-user-agent) on the upstream
  request, falling back to CCS-OpenAI-Compat-Proxy/1.0
- Skip SSE response transformation in passthrough mode (upstream
  already returns Anthropic-format bytes)

Tests:
- 9 new tests in upstream-url.test.ts covering auto-detection and the
  passthrough URL contract
- 2 new tests in profile-router.test.ts covering the env var

Verified end-to-end against api.kimi.com: a request through the
modified proxy returned a real Kimi response (model kimi-k2p7-coding)
with the original claude-cli/2.1.170 User-Agent preserved.
2026-06-13 01:39:49 +05:30
Tam Nhu Tran 8282ff68a1 fix(proxy): support opt-in OpenAI reasoning shaping 2026-06-03 11:08:41 -04:00
Halil ErtekinandGitHub f42aee9a20 fix: handle system messages in OpenAI proxy (#1403) 2026-05-28 22:08:07 -04:00
Kai (Tam Nhu) TranandGitHub 24478135dc fix(proxy): scope insecure TLS to routed profile
Squash merge PR #1299 into dev.
2026-05-19 08:13:40 -04:00
Kai (Tam Nhu) TranandGitHub a840793a9b fix(proxy): avoid exposing local auth token in daemon argv (#1230) 2026-05-12 18:13:20 -04:00
Tam Nhu Tran dc8bbd85e7 fix: route OpenRouter profiles through v1 API 2026-05-05 11:44:58 -04:00
4e2def6769 feat: support ollama cloud anthropic compatible api (#1175)
* feat(droid-provider): support ollama cloud anthropic compatible api

* fix(droid-provider): move ollama.com to anthropic block to prevent model inference override

* fix(droid-provider): move pathname-based generic checks before host-based anthropic check

* test(proxy): cover ollama cloud native routing boundaries

---------

Co-authored-by: Tam Nhu Tran <kaitran.ntt@gmail.com>
2026-05-03 22:28:38 -04:00
seilk 2c0f9c41ff test(proxy): assert tool_result image URLs stay redacted 2026-04-30 02:22:49 +09:00
seilk 83c16e216a fix(proxy): avoid leaking tool_result image URLs 2026-04-30 02:18:22 +09:00
seilk f6bb31c956 fix(proxy): stringify tool_result images for OpenAI upstreams 2026-04-30 00:55:45 +09:00
Chris Weller 1c91c46326 fix(proxy): avoid settings override and nested reasoning for openai-compat 2026-04-26 14:53:25 -06:00
Tam Nhu Tran d5591913ef fix(proxy): clarify shared port fallback and legacy 3456 handling 2026-04-23 15:00:50 -04:00
Tam Nhu Tran 15751e2db5 feat(proxy): add adaptive local port selection for OpenAI-compatible profiles 2026-04-23 14:47:01 -04:00
Tam Nhu Tran 71deda553a fix(cliproxy): preserve adaptive thinking on opus 4.7 paths 2026-04-22 21:43:11 -04:00
Tam Nhu Tran 399f403322 fix(transformers): preserve tool ordering across proxy streams
- reject pending tool_result layouts that cannot be translated without reordering user content

- keep interleaved GLMT tool_use blocks open until finalization instead of stopping early

- cover leading/interleaved tool_result regressions and interleaved streaming tool fragments
2026-04-20 13:17:30 -04:00
Grandis SYFandTam Nhu Tran 889d3d89e9 fix(test): correct expected error message text 2026-04-20 13:06:00 -04:00
Grandis SYFandTam Nhu Tran b2a4579098 fix(proxy): update tests for tool_result+text and disconnect handler changes 2026-04-20 13:06:00 -04:00
Tam Nhu Tran 1cfed73ca5 fix(proxy): harden stale daemon ownership checks 2026-04-20 12:44:30 -04:00
Wooseong Kim 8ad2763942 fix(proxy): retry candidate ports on bind conflict 2026-04-20 14:59:59 +09:00
Wooseong Kim f345cf441e fix(proxy): ignore legacy singleton session file 2026-04-20 14:09:50 +09:00
Wooseong Kim 8942be3afc test(proxy): cover multi-profile daemon ports 2026-04-20 13:14:19 +09:00
Tam Nhu Tran ebc92194bb fix(proxy): harden Anthropic request transformation semantics
- enforce strict tool_result ordering and pairing against assistant tool_use ids
- reject tool_result image payloads that cannot map to OpenAI tool messages
- preserve raw tool schemas on the /v1/messages proxy path instead of silently tightening them
- forward Anthropic tool_choice semantics and cover adaptive routing plus upstream payload checks
2026-04-18 19:39:13 -04:00
Tam Nhu Tran 32d6bfdda7 fix(proxy): restore strict Anthropic message validation 2026-04-18 19:02:38 -04:00
Tam Nhu Tran 1923d87a84 chore: merge dev into openai provider routing 2026-04-15 20:36:03 -04:00
Tam Nhu Tran a3407093d7 refactor(proxy): internalize sse translation and cleanup handlers 2026-04-15 01:44:01 -04:00
Tam Nhu Tran 17187c4abd feat(proxy): complete openai routing scope 2026-04-15 00:55:11 -04:00
Tam Nhu Tran a6aa576d5a fix(proxy): detect dashscope compatible-mode profiles 2026-04-14 23:49:34 -04:00
Tam Nhu Tran 5c66c1f121 test(proxy): cover proxy lifecycle and routing 2026-04-14 19:27:19 -04:00