Skip to content

Commit 33b444d

Browse files
committed
fix(anthropic): pdf-native-providers reuses resolveAnthropicMessagesUrl
Greptile flagged two issues with the inline URL build: P1 (real bug): the chain used `??` instead of `||`, so a whitespace-only ANTHROPIC_BASE_URL trimmed to "" passed nullish-checks and produced a relative `/v1/messages` URL that fetch() can't resolve. P2 (pre-existing): the inline path always appended `/v1/messages`, so a proxy URL ending in `/v1` (common with LiteLLM) would hit `/v1/v1/messages`. Both fixed by reusing the canonical resolveAnthropicMessagesUrl helper — single precedence chain, single `/v1` suffix logic, no duplication.
1 parent c62881c commit 33b444d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/agents/tools/pdf-native-providers.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { normalizeProviderTransportWithPlugin } from "../../plugins/provider-runtime.js";
77
import { isRecord } from "../../utils.js";
88
import { normalizeSecretInput } from "../../utils/normalize-secret-input.js";
9+
import { resolveAnthropicMessagesUrl } from "../anthropic-transport-stream.js";
910

1011
type PdfInput = {
1112
base64: string;
@@ -62,12 +63,8 @@ export async function anthropicAnalyzePdf(params: {
6263
}
6364
content.push({ type: "text", text: params.prompt });
6465

65-
const baseUrl = (
66-
params.baseUrl ??
67-
process.env.ANTHROPIC_BASE_URL?.trim() ??
68-
"https://api.anthropic.com"
69-
).replace(/\/+$/, "");
70-
const res = await fetch(`${baseUrl}/v1/messages`, {
66+
const url = resolveAnthropicMessagesUrl(params.baseUrl);
67+
const res = await fetch(url, {
7168
method: "POST",
7269
headers: {
7370
"Content-Type": "application/json",

0 commit comments

Comments
 (0)