From 8c2d3d78d5d110aacc6ff40539f57e577f5d7995 Mon Sep 17 00:00:00 2001 From: "developerz-ai[bot]" <286432749+developerz-ai[bot]@users.noreply.github.com> Date: Mon, 9 Nov 2026 12:44:22 +0000 Subject: [PATCH] fix: emit tool_call in generated opencode.json model entries The model-level "tools": true is not a field in the opencode v1 provider-model schema (tool_call is) and was silently dropped. Emit tool_call: true in the local and remote configs. The rest of the shape (provider/npm/options, autoupdate, top-level tools block) is valid in opencode v1.18.21 and normalized by 2.x. Record the schema reference in the generator comment and pin the shape in tests. Dz-Task-Id: tsk_686da5ed67418b4a3a2f6a8123831414 --- lib/opencode.sh | 12 ++++++++++-- tests/opencode_config_test.sh | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/opencode.sh b/lib/opencode.sh index 230e8e3..685b6f7 100644 --- a/lib/opencode.sh +++ b/lib/opencode.sh @@ -216,6 +216,14 @@ opencode_install_config() { # $3/$4 serve the run-only --model override: it writes a run-scoped config # of that launch's own while carrying user commands from — and never # touching — the live config. +# +# Schema reference: opencode v1.18.21 config.ts + core/src/v1/config/provider.ts +# (opencode.ai/docs/migrate-v1/). A model declares tool support with +# "tool_call": true — a model-level "tools" key is not in the schema and is +# silently dropped. The v1 keys below (provider npm/options, top-level tools, +# autoupdate, share) are normalized by v2; never emit v2-native keys here +# (providers, permissions, agents, commands): v1 would ignore them. +# # Note the "tools" block — it is a latency setting, not a preference. # # Every enabled tool ships its JSON schema in the prompt on EVERY request. @@ -289,7 +297,7 @@ opencode_write_config() { "models": { "${model}": { "name": "$(json_escape "$label")", - "tools": true, + "tool_call": true, "limit": { "context": ${ctx}, "output": ${out_tokens} } } } @@ -561,7 +569,7 @@ opencode_write_remote_config() { "models": { "$(json_escape "$model")": { "name": "$(json_escape "mini · ${model}")", - "tools": true, + "tool_call": true, "limit": { "context": ${ctx}, "output": ${out_tokens} } } } diff --git a/tests/opencode_config_test.sh b/tests/opencode_config_test.sh index cef02d0..00b66e7 100644 --- a/tests/opencode_config_test.sh +++ b/tests/opencode_config_test.sh @@ -451,5 +451,42 @@ assert_eq 'two writes: the temp file sits beside the destination' 'same dir' \ && printf 'same dir' || printf 'elsewhere')" assert_true 'two writes: the live config is still valid JSON' json_ok "$CFG" +# --- 9: schema contract — opencode v1 keys only ----------------------------- + +# opencode v1.18.21 (config.ts + core/src/v1/config/provider.ts) declares model +# tool support as "tool_call"; a model-level "tools" key is not in the schema and +# is silently dropped. The top-level "tools" block and the provider block are +# v1 syntax that v2 normalizes (opencode.ai/docs/migrate-v1/), and v2-native +# keys would be ignored by v1. Asserted on freshly generated output of both +# writers: the local config is regenerated here, the remote one is section 3's. + +run_case case_two_writes_two_temps # leaves a fresh local config in $CFG +assert_eq 'schema: regenerated local config' '0' "$RUN_RC" + +schema_checks() { #