openwork icon indicating copy to clipboard operation
openwork copied to clipboard

[Bug]: After update from Versión 0.18.58 to Versión 0.18.60 (0.18.60)

Open mnlrioiv opened this issue 1 month ago • 4 comments

Summary

Invalid schema for function 'computer_run': Pointer '/$defs/__schema0' does not exist (request_id: b9cf7e35-29c1-456f-9f1c-d8128cb2bb56) Image

To Reproduce

I updated to Versión 0.18.60 (0.18.60) and tried to continue with a chat and got that error, same with new chats Macos

Expected behavior

Continue with chats old and new ones

Actual behavior

Invalid schema for function 'computer_run': Pointer '/$defs/__schema0' does not exist (request_id: b9cf7e35-29c1-456f-9f1c-

Image

Screenshots (optional)

No response

OW version & Desktop info (optional)

No response

Additional context (optional)

No response

mnlrioiv avatar Oct 22 '26 23:10 mnlrioiv

Me too. Version v0.18.62. Same behavior. Windows 11

pacommun avatar Oct 24 '26 14:10 pacommun

Confirmed on 0.18.62 (macOS 26.6.2, opencode engine 1.18.33) with DeepSeek, and this blocks every message, not just computer-use calls.

Request ids: b5133a09-108b-42f1-95ab-9c5a8d15f1e4, f6d8196e-b59a-4e31-b2c4-7677850703e3

Root cause

Contents/Resources/opencode-plugins/openwork-computer-use.js registers computer_run with:

input: exports_external.json().optional(),   // zod 4.3.6, z.json()

Zod 4 renders that recursive type as:

"input": { "$ref": "#/$defs/__schema0" },
"$defs": { "__schema0": { ... } }

The $defs block does not travel with the tool parameters inside tools[].function.parameters, so the $ref dangles. DeepSeek validates function schemas strictly and rejects the whole request before the model runs:

AI_APICallError: Invalid schema for function 'computer_run':
Pointer '/$defs/__schema0' does not exist

Because the broken tool is in the tool list, unrelated prompts (e.g. "find this file") fail the same way. Other strict OpenAI-compatible endpoints probably fail too.

Verified local workaround

A fetch-level patch that inlines local $ref, drops $defs/$schema, and falls back to a permissive schema when the reference target is missing. Reproduction outside the app:

sidecars/opencode run -m deepseek/deepseek-flash "reply with exactly: ok"
→ Invalid schema for function 'computer_run' ...        (before)
→ ok                                                     (after the patch)

The patch reports inlined=0, permissive=1, which confirms the $defs block is missing from the outgoing body rather than misplaced.

Suggested fix

  • Replace input: z.json() with z.any() or z.record(z.string(), z.unknown()). input is optional JSON, so nothing is lost, and the tool schema becomes self-contained.
  • Or run a deref/sanitize pass over tools[].function.parameters for every provider, not only Anthropic — openwork-anthropic-tool-schema.js already patches outgoing bodies per provider, so the same hook can repair $ref/$defs for OpenAI-compatible endpoints.

Happy to test a build with either change.

benjaminmasika93-svg avatar Oct 25 '26 09:10 benjaminmasika93-svg

Additional data point on Windows 11, with the same root cause — and it also reproduces on the OpenCode v2 engine, so it is not fixed by moving off the 1.x engine.

Environment

  • OpenWork 0.18.62 (desktop), engine-v2 preview enabled
  • OpenCode engine v2.1.4
  • Provider: DeepSeek via @ai-sdk/openai-compatible (https://api.deepseek.com), model deepseek-v4-flash
  • Windows 11 Pro, build 26300

Symptom

Every message fails before the model runs, e.g. the prompt ciao:

Invalid schema for function 'computer_run': Pointer '/$defs/__schema0' does not exist (request_id: 4b1ee10d-fdd4-430c-8961-4d766af9bdcc)

Confirmed cause and exact locations

resources/opencode-plugins/openwork-computer-use.js in 0.18.62, two occurrences:

  • L13719 — the tool args schema
  • L13722 — the runtime ...strict().parse(raw)

Both use input: exports_external.json().optional(). Zod 4 renders that recursive type as:

"input": { "$ref": "#/$defs/__schema0" },
"$defs": { "__schema0": { ... } }

The $defs block is not present in the outgoing tools[].function.parameters, so the $ref dangles and DeepSeek rejects the whole request.

Verified fix

Replacing both occurrences with z.any():

  • the plugin still loads and registers all 9 computer_* tools
  • the generated schema then contains no $ref and no $defs at all
  • DeepSeek responds normally again

input is optional free-form JSON, so z.any() loses nothing functional. Patching only L13719 fixes the schema error but leaves the runtime parser on z.json(); both should change together.

Agree with the second suggestion above: a deref/sanitize pass over tools[].function.parameters per provider (the existing openwork-anthropic-tool-schema.js hook already does body-level patching) would stop any future recursive schema from breaking strict OpenAI-compatible endpoints.

lucad87 avatar Oct 25 '26 09:10 lucad87

Thanks everyone for the reports and root-cause details. This is fixed in v0.18.63:

  • #6491 removes the $defs / $ref pointer from the computer_run tool schema (and a test checks every computer tool schema for leftover $defs pointers).
  • #6493 adds a safety check: on v2, any OpenWork tool with an unsupported schema is now left out (with a warning) instead of failing every message.

Please update to v0.18.63 or later. If you still see Invalid schema for function ... on a current version, please reopen with the version, engine (v1/v2) and model provider.

OmarMcAdam avatar Oct 28 '26 23:10 OmarMcAdam