refactor(codemode): dispatch all tool calls positionally#1547
Conversation
🦋 Changeset detectedLatest commit: 141ea4e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
a97a7c2 to
118c63f
Compare
| typeof provider.name === "string" && | ||
| (provider.positionalArgs === undefined || | ||
| typeof provider.positionalArgs === "boolean") | ||
| isRecord(provider) && typeof provider.name === "string" && true |
There was a problem hiding this comment.
🟡 Residual && true in type guard from incomplete cleanup
When removing the positionalArgs validation from isExecuteRequestMessageShape, the old check (provider.positionalArgs === undefined || typeof provider.positionalArgs === "boolean") was replaced with just true instead of being removed entirely. This leaves a dead && true in the .every() predicate at packages/codemode/src/messages.ts:101, which is a no-op but clearly an artifact of an incomplete transformation.
| isRecord(provider) && typeof provider.name === "string" && true | |
| isRecord(provider) && typeof provider.name === "string" |
Was this helpful? React with 👍 or 👎 to provide feedback.
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
| const args = argsJson ? parseForCodemode(argsJson) : {}; | ||
| const result = await fn(args); |
There was a problem hiding this comment.
This is very slightly behaviour-changing in edge cases, I think. If args was undefined, we previously sent an empty object, but will now send undefined. Does that matter?
There was a problem hiding this comment.
I think I'm happy with this change. feel more correct if everything is positional.
There was a problem hiding this comment.
the ai sdk libs would have normalised this anyway. It would only be weird for people doing custom implementation in which case this was broken before so I think I'm actually fine with this being a patch.
bc0b81e to
7598dc9
Compare
7598dc9 to
265b41c
Compare
Summary
Simplify codemode tool dispatch by treating every sandbox tool call as positional.
Previously providers could opt into
positionalArgs, which made the sandbox proxy capture(...args)and made the dispatcher spread those args into the host function. Providers without the flag used a separate single-object path.This PR removes that split. The sandbox proxy now always captures an argument list and the dispatcher always calls:
Object-style calls still work naturally because they are just one positional argument:
Changes
positionalArgsfromResolvedProviderandToolProviderToolDispatcher.positionalArgspositionalArgs: true.backup.tsto the real test file and merge the existing small TanStack test into itVerification
npm test --workspace @cloudflare/codemode -- --run npm run build npm run check