Skip to content

feat(think): add tool call repair - #2062

Open
ben-reitz wants to merge 1 commit into
mainfrom
feat/think-tool-call-repair
Open

feat(think): add tool call repair#2062
ben-reitz wants to merge 1 commit into
mainfrom
feat/think-tool-call-repair

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #1974.

What changed

Think now exposes the AI SDK's tool-call repair callback as TurnConfig.repairToolCall. This lets applications correct unknown tools or malformed inputs before Think's tool hooks and execution.

Think forwards the callback through experimental_repairToolCall, the shared option name across supported AI SDK v6 and v7 versions, while presenting the stable name in its public API. Function-valued callbacks must be configured from a Think subclass rather than a sandboxed extension over RPC.

Tests

Added a worker-level test that repairs fenced JSON, verifies the repaired input reaches both tool hooks, and confirms the tool executes exactly once. Updated Think's lifecycle docs and README.

Verified all 921 Think worker tests and typechecking against AI SDK v6 and v7, plus pnpm run build and pnpm run check.


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2786420

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/think Patch
@cloudflare/agent-think Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2062

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2062

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2062

create-think

npm i https://pkg.pr.new/create-think@2062

hono-agents

npm i https://pkg.pr.new/hono-agents@2062

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2062

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2062

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2062

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2062

commit: 2786420

@ben-reitz ben-reitz added the ready-for-review-and-merge PR is ready for review and/or merge label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review-and-merge PR is ready for review and/or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose experimental_repairToolCall on Think's TurnConfig

1 participant