Skip to content

feat: add Responses, Anthropic, and Antigravity compatible endpoints with thinking tier probing - #442

Open
Kurisu934 wants to merge 1 commit into
ProfSynapse:mainfrom
Kurisu934:feat/compatible-protocols-and-thinking-probe
Open

Kurisu934 wants to merge 1 commit into
ProfSynapse:mainfrom
Kurisu934:feat/compatible-protocols-and-thinking-probe

Conversation

@Kurisu934

Copy link
Copy Markdown

Extends the custom endpoint architecture introduced in #405 and #441 to cover third-party OpenAI Responses, Anthropic Messages, and Antigravity (v1beta + messages) gateways, and unlocks model-specific thinking effort tiers from passive /models metadata and active endpoint probing across all four compatible provider drivers.

What changes

  • Three additional multi-instance compatible endpoint drivers (desktop and mobile, zero vendor SDKs, reusing ProviderHttpClient and app.secretStorage):
    • responses-compatible (/v1/responses and /codex/responses): supports Stateless full-input replay (store: false, instructions, and function_call / function_call_output items — safe across multi-account gateways) and Stateful previous_response_id continuations, configurable Bearer / x-api-key / dual auth headers, reasoning summary streaming, and automatic SSE stream-collection fallback when Codex-backed endpoints reject stream: false.
    • anthropic-compatible (/v1/messages): reuses AnthropicAdapter with configurable base URLs (root, /v1, or prefixed gateway paths), x-api-key / Bearer / dual auth headers, /v1/models → /models discovery fallback, native tool calling, vision, and signed anthropic_thinking_blocks / anthropic_response_content replay across tool continuations.
    • antigravity-compatible (v1beta + messages HTTP gateways, distinct from the desktop agy CLI): supports Auto routing (gemini-* via {root}/v1beta/models/{model}:streamGenerateContent?alt=sse, claude-* via {root}/v1/messages with concurrent dual-catalog discovery) as well as forced v1beta-only or messages-only modes, preserving thought_signature across tool rounds.
  • Discovery-driven and probe-driven thinking effort tiers across all compatible protocols (openai-compatible, responses-compatible, anthropic-compatible, antigravity-compatible):
    • Passive discovery (Connect, zero token cost): reads supported_reasoning_levels, reasoning, thinking (including Gemini /v1beta/models), supports_reasoning, and supported_openai_params when advertised by the server.
    • Active per-model Probe button (alongside #441's context-window Check button in both OpenAICompatibleModal and CustomCompatibleModal): sends minimal requests with a sentinel validation guard (preventing false positives on permissive servers that ignore unknown fields) to detect exact accepted effort tiers (low, medium, high, xhigh, max) and wire modes (adaptive vs budget on Anthropic Messages; thinkingLevel vs thinkingBudget on Gemini v1beta; reasoning_effort / reasoning.effort on OpenAI Chat & Responses).
    • UI & outbound clamping: modelCapabilities.ts and thinkingLevels.ts expose only the model's supported effort levels in chat settings and clamp outbound requests (including wiring reasoning_effort on OpenAICompatibleAdapter when thinking is enabled).
  • HTTPS & startup invariants preserved: keeps remote HTTPS enforcement (loopback HTTP allowed for local servers), no static Node built-in imports on the mobile startup path, and extractError / extractResponsesApiStreamError wired on every streaming surface.

Verification

  • Stream error wiring gate: python3 .skills/nexus-llm-adapters/scripts/check_stream_error_wiring.py --repo-root . --strict passes (15/15 streaming adapters clean).
  • Build, ESLint & mobile reachability gate: npm run build passes (schemas:check, eslint . including obsidianmd/ui/sentence-case, node scripts/check-mobile-imports.mjs, tsc --noEmit, production bundle).
  • Test suite: npm test passes across all 584 suites (7,268 passed, 0 failed), including new suites:
    • tests/unit/ResponsesCompatibleAdapter.test.ts
    • tests/unit/AnthropicCompatibleAdapter.test.ts
    • tests/unit/AntigravityCompatibleAdapter.test.ts
    • tests/unit/CompatibleThinkingTiers.test.ts
  • Local TCP/SSE socket smoke: verified buffered generation, incremental wire SSE (thinking + text + tool calls + continuation signatures), mid-stream HTTP-200 error frames (PROVIDER_STREAM_ERROR), and live HTTP tier probing across all four protocols against local node:http test gateways.

@ProfSynapse

Copy link
Copy Markdown
Owner

Thanks for putting this together — it's clearly a lot of work, and the build and tests pass on my end.

Before going further, can you help me understand the use case? What setup are you running that needs these endpoint types, and who else would use them?

I ask because a lot of this reads as being built for proxy gateways that wrap consumer subscriptions (Codex / ChatGPT, Antigravity, Claude) into an API — the "multi-account gateway" wording, the /backend-api/codex, /sub2api and /antigravity paths, and the Antigravity gateway type in particular. That kind of CLI/subscription proxy setup is something we don't want to support in Nexus, so I won't be merging those parts.

If there's a standard use case here (e.g. a company gateway or a provider that serves the Anthropic Messages or OpenAI Responses format at its own URL), I'm open to hearing it — ideally as a smaller, focused PR without the proxy-specific pieces, since this one also changes shared code paths for the built-in Anthropic, Google and OpenAI-compatible providers.

@Kurisu934

Copy link
Copy Markdown
Author

Makes total sense — completely understood on keeping CLI/subscription wrappers out of Nexus. Happy to drop antigravity-compatible altogether along with the /codex path handling, stream-only Codex fallback, and proxy-specific docs/fixtures.

On the standard API side, there are three non-proxy gaps I ran into because the built-in openai, anthropic, and google drivers are pinned to official hostnames and static model catalogs:

  1. Reasoning effort on existing openai-compatible endpoints (#405 / #441)

    • OpenAICompatibleAdapter currently reads reasoning from responses but doesn't forward reasoning_effort on requests, and custom models have no way to surface supported effort tiers in chat settings.
    • Standard targets: self-hosted vLLM / SGLang / llama.cpp and enterprise AI gateways (LiteLLM, Cloudflare AI Gateway, Portkey) serving reasoning models over /v1/chat/completions.
  2. Standard anthropic-compatible (/v1/messages at a custom base URL)

    • Built-in AnthropicAdapter is hardcoded to https://api.anthropic.com and ANTHROPIC_MODELS.
    • Standard targets: enterprise gateways passing through /v1/messages with commercial keys (Cloudflare AI Gateway, LiteLLM, Portkey, internal company gateways) and commercial model APIs that natively serve an official Anthropic Messages endpoint (e.g., MiniMax, Z.ai / GLM, Kimi), where falling back to /v1/chat/completions loses signed thinking block replay across tool continuations.
  3. Standard responses-compatible (/v1/responses at a custom base URL)

    • Built-in OpenAIAdapter is hardcoded to https://api.openai.com/v1 and OPENAI_MODELS.
    • Standard targets: self-hosted vLLM's /v1/responses server, Azure /openai/v1 Responses endpoints, and enterprise gateways running Zero Data Retention (store: false full-item replay) or standard previous_response_id continuations.

Dropping antigravity-compatible also eliminates all changes to GoogleAdapter, and splitting the rest avoids touching unrelated built-in paths at once.

If any of these fit Nexus's scope, I can close #442 and open small, independent PRs for whichever slice(s) you want — for example:

  • Slice 1: openai-compatible reasoning_effort forwarding + metadata/probe tier detection (only touches the existing #405/#441 path; zero new drivers, zero changes to built-in AnthropicAdapter or GoogleAdapter).
  • Slice 2: Standard anthropic-compatible (/v1/messages custom base URL, no proxy-specific paths).
  • Slice 3: Standard responses-compatible (strict /v1/responses spec only — no /codex suffix or stream-only proxy fallback).

Let me know which of these (if any) you'd welcome, and I'll scope accordingly.

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.

2 participants