@dbx-tools/cli-model-proxy 0.3.25 → 0.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/server.ts +20 -4
package/package.json CHANGED
@@ -18,16 +18,16 @@
18
18
  "@databricks/sdk-experimental": "^0.17.0",
19
19
  "commander": "^15.0.0",
20
20
  "tsx": "^4.23.0",
21
- "@dbx-tools/model": "0.3.25",
22
- "@dbx-tools/shared-model": "0.3.25",
23
- "@dbx-tools/shared-core": "0.3.25"
21
+ "@dbx-tools/model": "0.3.26",
22
+ "@dbx-tools/shared-core": "0.3.26",
23
+ "@dbx-tools/shared-model": "0.3.26"
24
24
  },
25
25
  "main": "index.ts",
26
26
  "license": "UNLICENSED",
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "version": "0.3.25",
30
+ "version": "0.3.26",
31
31
  "types": "index.ts",
32
32
  "type": "module",
33
33
  "exports": {
package/src/server.ts CHANGED
@@ -38,7 +38,8 @@ import { classify, openaiChat, openaiResponses } from "@dbx-tools/shared-model";
38
38
  import type { DatabricksBackend } from "./backend";
39
39
  import { DEFAULT_BIND_HOST, DEFAULT_PORT } from "./defaults";
40
40
 
41
- const { chatToResponsesRequest, responseToChatCompletion } = openaiResponses;
41
+ const { chatToResponsesRequest, responseToChatCompletion, sanitizeResponsesTools } =
42
+ openaiResponses;
42
43
 
43
44
  const logger = log.logger("model-proxy/server");
44
45
 
@@ -329,6 +330,10 @@ async function proxyChatViaResponses(
329
330
  * `POST /v1/responses`: forward the Responses body to Databricks' native
330
331
  * Responses / Open Responses surface (model stays in the body; URL is
331
332
  * workspace-level). Streaming and non-streaming both pass through as-is.
333
+ *
334
+ * Open Responses (Claude/Gemini/…) only accepts `function` tools, so Codex's
335
+ * built-in `web_search` / `local_shell` / … are stripped there. The OpenAI
336
+ * `/responses` path keeps them - GPT models support those tool types.
332
337
  */
333
338
  async function handleResponses(
334
339
  backend: DatabricksBackend,
@@ -345,24 +350,35 @@ async function handleResponses(
345
350
  const resolved = await backend.resolve(requested);
346
351
  body.model = resolved.modelId;
347
352
 
348
- const wantsStream = body.stream === true;
353
+ const upstreamUrl = backend.responsesUrl(resolved.modelId);
354
+ // Cross-provider Open Responses rejects non-function tool types; OpenAI
355
+ // `/responses` keeps Codex built-ins (web_search, local_shell, custom, …).
356
+ const forward = upstreamUrl.includes("/open-responses")
357
+ ? sanitizeResponsesTools(body)
358
+ : body;
359
+
360
+ const wantsStream = forward.stream === true;
349
361
  const headers = await backend.authHeaders();
350
362
  headers["content-type"] = "application/json";
351
363
  headers.accept = wantsStream ? "text/event-stream" : "application/json";
352
364
 
353
- const upstreamUrl = backend.responsesUrl(resolved.modelId);
365
+ const stripped =
366
+ Array.isArray(body.tools) &&
367
+ (!Array.isArray(forward.tools) || forward.tools.length !== body.tools.length);
368
+
354
369
  logger.info("responses", {
355
370
  requested,
356
371
  resolved: resolved.modelId,
357
372
  matched: resolved.matched,
358
373
  upstream: upstreamUrl,
359
374
  stream: wantsStream,
375
+ ...(stripped ? { strippedNonFunctionTools: true } : {}),
360
376
  });
361
377
 
362
378
  const upstream = await fetch(upstreamUrl, {
363
379
  method: "POST",
364
380
  headers,
365
- body: JSON.stringify(body),
381
+ body: JSON.stringify(forward),
366
382
  });
367
383
 
368
384
  res.writeHead(upstream.status, {