Skip to content

fix: normalize compute_job's tool schema for openai-compatible providers too - #471

Closed
Satya Arjunan (satya-arjunan) wants to merge 1 commit into
synthetic-sciences:mainfrom
satya-arjunan:fix/compute-job-schema-openai-compatible
Closed

Satya Arjunan (satya-arjunan) wants to merge 1 commit into
synthetic-sciences:mainfrom
satya-arjunan:fix/compute-job-schema-openai-compatible

Conversation

@satya-arjunan

@satya-arjunan Satya Arjunan (satya-arjunan) commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #472

Problem

compute_job's parameter schema is a z.discriminatedUnion("action", [...]) (backend/cli/src/tool/compute-job.ts:110), which Zod compiles to a root oneOf in JSON Schema. normalizeDeepSeekToolSchema (backend/cli/src/provider/tool-schema.ts) already exists to rewrite that into an object-rooted anyOf that plain function-calling parsers accept — but the call site (backend/cli/src/provider/transform.ts) only applied it when model.api.npm === "@ai-sdk/deepseek":

if (model.api.npm === "@ai-sdk/deepseek") {
  schema = normalizeDeepSeekToolSchema(schema)
}

openai-compatible providers (e.g. a local Ollama model) hit the exact same schema defect, just with a different failure mode: instead of the whole request being rejected the way DeepSeek's strict validator rejects it (#283, #298), the one tool with the unparseable root oneOf is silently dropped from the model's tool list — no error, nothing in the logs. compute_job has "allow" permission for the research agent, but a real session running a local Ollama model never saw it in its own available-tools list at all.

The existing test even locked this gap in as expected behavior:

test("runs only at the native DeepSeek provider boundary", () => {
  expect((ProviderTransform.schema(model("@ai-sdk/deepseek"), union as any) as any).type).toBe("object")
  expect((ProviderTransform.schema(model("@ai-sdk/openai-compatible"), union as any) as any).type).toBeUndefined()
})

Fix

Broaden the gate to @ai-sdk/deepseek || @ai-sdk/openai-compatible. The normalization function itself has no DeepSeek-specific logic — it's a generic root-oneOf-to-anyOf rewrite — so this just closes the gap for the other provider family that needs the same treatment. Also updated the doc comment (it previously read as if the fix were DeepSeek-exclusive) and fixed the test that asserted the old, incorrect boundary.

Verification

  • Updated test("runs only at the native DeepSeek provider boundary") → now also asserts @ai-sdk/openai-compatible gets normalized, and that an unrelated provider (@ai-sdk/anthropic) does not.
  • Added a regression test using compute_job's real discriminated-union schema shape against an openai-compatible-shaped model.
  • Full bun test across backend/cli: 2852 pass / 92 fail with this fix, vs. 2851 pass / 92 fail on a clean main baseline — identical failure set (unrelated, pre-existing), one new passing test, zero regressions.
  • bun run typecheck and prettier --check on all three changed files — clean.

…ers too

compute_job's parameter schema is a discriminatedUnion, which Zod compiles
to a root oneOf in JSON Schema. normalizeDeepSeekToolSchema already exists
to rewrite that into an object-rooted anyOf that plain function-calling
parsers accept, but the call site in transform.ts only applied it when
model.api.npm === "@ai-sdk/deepseek".

openai-compatible providers (e.g. a local Ollama model) hit the exact same
schema defect, just with a different failure mode: instead of the whole
request being rejected the way DeepSeek's strict validator rejects it, the
one tool with the unparseable root oneOf is silently dropped from the
model's tool list. compute_job has "allow" permission for the research
agent but never actually reached the model for an openai-compatible
provider - confirmed against a real local Ollama session.

Broadens the gate to include @ai-sdk/openai-compatible, and updates the
existing test that had locked in the old (incorrect) boundary as expected
behavior. Adds a regression test using compute_job's real discriminated
schema shape.
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

Satya Arjunan (@satya-arjunan) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

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.

compute_job silently missing from the tool list for openai-compatible providers (same schema defect as #283/#298, different failure mode)

2 participants