Skip to content

v0.42.19.0 fix(skillopt): close the last gap in the AI SDK v6 tool-loop fix (write-capture mapper + regression test)#1809

Merged
garrytan merged 4 commits into
masterfrom
garrytan/fix-ai-sdk-tool-schema
Jun 3, 2026
Merged

v0.42.19.0 fix(skillopt): close the last gap in the AI SDK v6 tool-loop fix (write-capture mapper + regression test)#1809
garrytan merged 4 commits into
masterfrom
garrytan/fix-ai-sdk-tool-schema

Conversation

@garrytan

@garrytan garrytan commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Context: master already landed the core fix

After merging origin/master, it turned out master independently landed the convergent AI SDK v6 tool-loop fix (toModelMessages + jsonSchema() wrap) in v0.42.11.0 (PR #1759, surfaced by the SkillOpt real-LLM eval). Same function name, same approach. So this PR is no longer "the v6 fix" — that's done. The merge took master's canonical gateway.ts + rollout.ts and dropped my now-redundant duplicate adapter + its unit test.

What this PR adds over master (the net delta)

Master's 0.42.11.0 fixed one of the two places skillopt builds tool definitions. This closes the other:

  • src/core/skillopt/write-capture.ts — the --write-capture virtual-write tool builder (put_page/submit_job/file_upload) still used the old {type,description}-only mapper, silently dropping enum/default/items from the schema the model sees. Now uses the shared paramDefToSchema, matching the rollout.ts builder master fixed.
  • test/ai/gateway-tools-schema.test.ts — real-AI-SDK integration test (generateText + MockLanguageModelV3, no network) that pins the gateway's tool-schema + tool-result shapes are accepted by AI SDK v6, with regression guards that the pre-fix bare-{jsonSchema} object AND raw-tool-result-in-a-user-message shapes both throw. The original fix lacked this; it makes the convergent fix impossible to silently regress.
  • test/skillopt/rollout-schema.test.ts — asserts enum survives in BOTH tool builders.

Verification

  • typecheck clean · bun run verify 30/30 · 25 tests pass across the merged gateway/skillopt suites (incl. master's toModelMessages unit test).
  • VERSION 0.42.19.0 (> master 0.42.16.0); CHANGELOG + TODOS merged.

The three original community PRs

Closed earlier with attribution — the core fix was convergent across master + #1748 (michaeladair44), #1742 (justemu, rejected: v4 parameters key), #1708 (JE4NVRG). Closes the remaining surface of #1782 / #1764.

🤖 Generated with Claude Code

garrytan and others added 2 commits June 2, 2026 23:48
#1764)

v6's asSchema() rejected the bare { jsonSchema } object and called it as a
function ("schema is not a function"), killing every tool-using agent run on
non-Anthropic providers and skillopt on all providers. Wrap tool inputSchema
with the SDK jsonSchema() helper, and add a pure toModelMessages() boundary
adapter in chat() that converts tool results to the v6 ModelMessage shape
(role:'tool' + typed output:{type:'json'|'error-text',value}, isError dropped,
non-JSON-safe output normalized). toolLoop stays provider-neutral and unchanged.
Both skillopt tool builders (rollout.ts, write-capture.ts) switch to the shared
paramDefToSchema mapper so enum/default/items survive. Tests run the produced
shapes through real generateText + MockLanguageModelV3.

Co-Authored-By: michaeladair44 <michaeladair44@users.noreply.github.com>
Co-Authored-By: justemu <justemu@users.noreply.github.com>
Co-Authored-By: JE4NVRG <JE4NVRG@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-tool-schema

# Conflicts:
#	CHANGELOG.md
#	CLAUDE.md
#	TODOS.md
#	VERSION
#	llms-full.txt
#	package.json
#	src/core/ai/gateway.ts
#	src/core/skillopt/rollout.ts
@garrytan garrytan changed the title v0.42.19.0 fix(ai/gateway): AI SDK v6 tool loop on non-Anthropic providers (#1782, #1764) v0.42.19.0 fix(skillopt): close the last gap in the AI SDK v6 tool-loop fix (write-capture mapper + regression test) Jun 3, 2026
…-tool-schema

# Conflicts:
#	CHANGELOG.md
#	VERSION
#	package.json
@garrytan garrytan merged commit 3d2add1 into master Jun 3, 2026
21 checks passed
garrytan added a commit that referenced this pull request Jun 3, 2026
Resolve conflicts:
- VERSION / package.json: keep wave version 0.42.20.0 (> master 0.42.19.0).
- CHANGELOG.md: keep both entries, 0.42.20.0 on top of master's stack
  (0.42.20.0 > 0.42.19.0 > 0.42.18.0 > ...).
- master's #1809 skillopt fix auto-merged into source; llms regenerated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mgunnin added a commit to mgunnin/gbrain that referenced this pull request Jun 3, 2026
* upstream/master:
  v0.42.23.0 feat(jobs): --nice scheduling-priority flag for jobs work/supervisor (garrytan#1815) (garrytan#1820)
  v0.42.22.0 fix(minions): supervisor progress watchdog + worker DB self-defense — alive-but-wedged worker self-heals (garrytan#1801) (garrytan#1824)
  v0.42.21.0 fix(postgres): module-singleton ownership — canonical landing for the dream-cycle "connect() has not been called" class (garrytan#1404/garrytan#1471/garrytan#1619) (garrytan#1805)
  v0.42.20.0 fix: reliability wave — PGLite capture lock-pin + Postgres reconnect race + search embed-hang (garrytan#1762 garrytan#1745 garrytan#1775) (garrytan#1810)
  v0.42.19.0 fix(skillopt): close the last gap in the AI SDK v6 tool-loop fix (write-capture mapper + regression test) (garrytan#1809)
  v0.42.18.0 fix: sync orphan-pileup watchdog (garrytan#1633) + links-lag µs stamp (garrytan#1768) (garrytan#1807)
  v0.42.17.0 fix(sync): resumable incremental sync — killed mid-import no longer loses progress (garrytan#1794) (garrytan#1808)
  v0.42.16.0 feat(doctor): brain health as a solved problem — cause-ranked doctor + OOM-loop line + auto-drain + pool-reap (garrytan#1685) (garrytan#1802)
  v0.42.15.0 fix: decouple CLI primary output from process.stdout.isTTY (garrytan#1784) (garrytan#1806)
  v0.42.14.0 fix(zero-config): code-* readiness signal + init embedding-key validation + lock self-heal (garrytan#1780) (garrytan#1804)
  v0.42.13.0 fix(search): archive/ content findable by default, demoted not hard-excluded (garrytan#1777) (garrytan#1797)
  v0.42.12.0 feat: self-upgrading gbrain — invocation-riding update check + opt-in auto-upgrade (garrytan#1798)
  v0.42.11.0 feat(skillopt): held-out eval gate, honest receipts, ENFORCE + ablation opts (garrytan#1759)
  v0.42.10.0 feat(extract): opt-in global-basename wikilink resolution (closes garrytan#972) (garrytan#1388)
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.

1 participant