Skip to content

DeepSeek rejects compute_job tool schema (zod discriminatedUnion); fix in source missing from 2.0.27 #298

Closed

Description

@DistortByte

Summary

Using any modal agent (research / biology / physics / ml) with the DeepSeek provider fails immediately: the DeepSeek API rejects the compute_job tool schema. The fix for this already exists in the source tree (transform.ts, commit b864fd47, Aug 8) but is missing from the released 2.0.27 (published Aug 15).

Invalid schema for function 'compute_job': schema must be a JSON Schema of 'type: "object"', got 'type: null'.

Environment

  • OpenScience 2.0.27 (latest on npm), any platform
  • Provider: deepseek (baseURL https://api.deepseek.com/v1)
  • Agent: any of research, biology, physics, ml (the only agents that register compute_job)
  • Any DeepSeek model (deepseek-v4-flash / deepseek-v4-pro / deepseek-chat / deepseek-reasoner)

Reproduction

  1. Configure the built-in (or a custom) DeepSeek provider pointing at api.deepseek.com.
  2. Start a session with a modal agent (e.g. research) and select a DeepSeek model.
  3. Send any message that triggers tool registration.

Expected: session proceeds. Actual: the request fails with the schema error above (the error text is returned by the DeepSeek API, not generated locally — it is not present anywhere in the bundle).

Root cause

  • compute_job (backend/cli/src/tool/compute-job.ts) is the only tool in the registry whose parameters are a zod discriminatedUnion.
  • zod v4's toJSONSchema serializes a discriminated union as a top-level { "anyOf": [...] } with no top-level type.
  • DeepSeek's OpenAI-compatible endpoint validates function parameters strictly and requires the top level to be type: "object"; an anyOf-only schema is rejected with got 'type: null'.

All other tools use plain z.object schemas (top-level type: "object"), which is why everything else works with DeepSeek.

The fix already exists but was not released

backend/cli/src/provider/transform.ts in the current source contains a DeepSeek-specific branch that flattens anyOf object branches into a merged { type: "object", properties, required } schema (committed Aug 8 in b864fd47, "feat(gewu): …"). I verified by extracting the embedded source map from the installed @synsci/[email protected] darwin-arm64 binary that this branch is absent from the released build, even though 2.0.27 was published on Aug 15 — after the commit.

Request

  1. Include commit b864fd47 (the transform.ts DeepSeek anyOf flatten) in the next release; and
  2. optionally, as a belt-and-braces fix at the tool level, replace compute_job's z.discriminatedUnion parameters with a plain object schema (action as a required enum + optional fields), keeping the strict union only for runtime validation inside execute — this keeps every tool DeepSeek-compatible regardless of provider transforms.

Workaround (for users on 2.0.27 meanwhile)

Route DeepSeek models through a lenient OpenAI-compatible gateway (e.g. an OpenRouter-style proxy) that does not enforce the top-level type: "object" requirement, or use a non-modal agent for DeepSeek sessions.

Activity

  1. aayambansal commented on Aug 18, 2026

    @aayambansal
    Member

    Solved in #299. The compute_job schema is object-rooted now, including its runtime action variants. Tested with DeepSeek compatibility coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions