GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — anthropic adapter: baseUrl ending in /v1/messages doubles the path, input_json_delta is not scoped to tool_use, and Anthropic-compatible relays need tool-call quirk tolerance · Issue #765 · lidge-jun/opencodex Closed Labels provider-compatibilityProvider compatibility reports DescriptionClient or integrationCodex CLI Provider or upstream serviceAgentRouter ( OpenCodex version2.7.43 Endpoint or capability
Current behaviour1. const base = provider.baseUrl.replace(/\/v1\/?$/, ""); const url = `${base}/v1/messages`; The regex only strips a trailing 2. } else if (delta.type === "input_json_delta" && typeof delta.partial_json === "string") { There is no check that the current content block is a 3. 4. Streams close without terminal frames. This relay sometimes ends an SSE stream after content blocks without Additionally, Expected behaviour
Items 1 and 2 look like plain correctness fixes worth applying unconditionally. Items 3-5 are quirk tolerance and could reasonably be gated per provider — locally I gate them on the endpoint hostname, but a capability flag on the provider config would be cleaner and would not hard-code a vendor name in the adapter. Minimal redacted request or reproductionConfigure an Anthropic-compatible provider and route a tool-using model through it: {
"id": "<provider-id>",
"type": "anthropic",
"baseUrl": "https://<host>/v1/messages",
"authMode": "key",
"apiKey": "<redacted>"
}
Actual response or errorProblem 1 — the composed URL: Problem 3/5 — what reaches the client: { "type": "tool_call_start", "id": "", "name": "shell" }
{ "type": "tool_call_delta", "arguments": "\"{\\\"command\\\":[\\\"ls\\\"]}\"" }Expected: { "type": "tool_call_start", "id": "toolu_<generated>", "name": "shell" }
{ "type": "tool_call_delta", "arguments": "{\"command\":[\"ls\"]}" }Problem 4 — the stream simply stops after the last Upstream documentation
Suggested mapping or implementation notesWhat I run locally, in case it is useful: // 1. Tolerate /, /v1 and /v1/messages suffixes. export function anthropicMessagesUrl(baseUrl: string): string { const base = baseUrl.replace(/\/(?:v1(?:\/messages)?)?\/?$/, ""); return `${base}/v1/messages`; } // 3. Synthesise a correlatable id when the provider omits one. function ensureAnthropicToolUseId(id: unknown): string { return typeof id === "string" && id.trim() !== "" ? id : `toolu_${crypto.randomUUID().replace(/-/g, "")}`; } // 5. Accept a JSON string, recovering from a malformed prefix, and emit one object. function normalizeAnthropicToolInput(input: unknown): string { let value = input; if (typeof input === "string") { const raw = input; try { value = JSON.parse(raw); } catch { for (let index = raw.lastIndexOf("{"); index >= 0; index = raw.lastIndexOf("{", index - 1)) { try { value = JSON.parse(raw.slice(index)); break; } catch { /* try an inner object */ } } } } return value && typeof value === "object" && !Array.isArray(value) ? JSON.stringify(value) : "{}"; } For problem 2 the fix is just adding the block-type guard: } else if (currentBlockType === "tool_use" && delta.type === "input_json_delta" && ...) { For problem 4 I track whether any content was seen and emit the completion event when the stream ends without a terminator. One convention note worth documenting. Any per-provider predicate that can throw on a malformed Additional context and attachmentsHappy to send a PR. Items 1 and 2 are two-line unconditional fixes; for 3-5 I would rather add a small provider capability flag than hard-code a hostname, and would welcome a hint on the shape you would accept. Checks
Activity
MetadataMetadataAssigneesLabelsprovider-compatibilityProvider compatibility reports TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |