-
Notifications
You must be signed in to change notification settings - Fork 619
[AI SDK Provider] Update sign swap action type with token fields #7988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AI SDK Provider] Update sign swap action type with token fields #7988
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 38831fc 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 |
WalkthroughAdds from_token and to_token fields to the sign_swap action input by extending the schema and propagating these fields into the provider’s SignSwapInput construction. Includes a changeset entry for a patch release. Changes
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7988 +/- ##
=======================================
Coverage 56.52% 56.53%
=======================================
Files 904 904
Lines 58623 58626 +3
Branches 4146 4146
=======================================
+ Hits 33138 33145 +7
+ Misses 25380 25375 -5
- Partials 105 106 +1
🚀 New features to boost your workflow:
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/ai-sdk-provider/src/tools.ts (1)
24-31: Tighten schema constraints for token fieldsSmall validations reduce bad payloads without breaking legit inputs:
const AgentActionSignSwapDataToken = z.object({ address: z.string(), - chain_id: z.number(), + chain_id: z.number().int().positive(), amount: z.string(), symbol: z.string(), - decimals: z.number(), - price: z.number().nullable(), + decimals: z.number().int().min(0).max(255), + price: z.number().nonnegative().nullable(), });Optional: add a reusable exported alias for downstream typing:
export type SignSwapToken = z.infer<typeof AgentActionSignSwapDataToken>;packages/ai-sdk-provider/src/provider.ts (1)
456-458: Map-through looks correct; add guard or validate to avoid malformed tool-callsThe new fields are forwarded as-is. If backend events lag this change, tool input may fail schema validation. Consider a minimal guard (log + skip enqueue) or runtime validation before emitting the tool call.
If you prefer a guard, one option:
case "sign_swap": toolName = "sign_swap"; - input = { + if (!parsed.data.from_token || !parsed.data.to_token) { + console.warn("sign_swap missing token fields", parsed.data); + break; + } + input = { action: parsed.data.action, intent: parsed.data.intent, transaction: parsed.data.transaction, from_token: parsed.data.from_token, to_token: parsed.data.to_token, } satisfies SignSwapInput; break;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.changeset/quiet-llamas-chew.md(1 hunks)packages/ai-sdk-provider/src/provider.ts(1 hunks)packages/ai-sdk-provider/src/tools.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md: Each change inpackages/*must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/quiet-llamas-chew.md
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/ai-sdk-provider/src/tools.tspackages/ai-sdk-provider/src/provider.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
packages/ai-sdk-provider/src/tools.tspackages/ai-sdk-provider/src/provider.ts
🧠 Learnings (2)
📚 Learning: 2025-08-28T20:50:33.170Z
Learnt from: joaquim-verges
PR: thirdweb-dev/js#7922
File: apps/playground-web/src/app/ai/ai-sdk/components/chat-container.tsx:167-181
Timestamp: 2025-08-28T20:50:33.170Z
Learning: The thirdweb-dev/ai-sdk-provider schemas use snake_case field naming convention (e.g., chain_id, transaction_hash) rather than camelCase, as defined in the zod schemas in packages/ai-sdk-provider/src/tools.ts.
Applied to files:
packages/ai-sdk-provider/src/tools.ts
📚 Learning: 2025-08-28T20:50:33.170Z
Learnt from: joaquim-verges
PR: thirdweb-dev/js#7922
File: apps/playground-web/src/app/ai/ai-sdk/components/chat-container.tsx:167-181
Timestamp: 2025-08-28T20:50:33.170Z
Learning: The SignTransactionInput schema in thirdweb-dev/ai-sdk-provider uses snake_case field names (chain_id) rather than camelCase (chainId).
Applied to files:
packages/ai-sdk-provider/src/provider.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Size
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/ai-sdk-provider/src/tools.ts (1)
37-38: LGTM: explicitfrom_token/to_tokenshapeSchema aligns with snake_case convention and keeps the runtime contract clear.
Confirm backend SSE action payloads always include these objects to avoid runtime parse failures when tools validate input.
| --- | ||
| "@thirdweb-dev/ai-sdk-provider": patch | ||
| --- | ||
|
|
||
| Update sign swap action type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Semver: use a minor bump (public API changed)
SignSwapInput gained new required fields (from_token, to_token). Per repo guidelines, this is a public API modification → minor, not patch.
Apply:
-"@thirdweb-dev/ai-sdk-provider": patch
+"@thirdweb-dev/ai-sdk-provider": minorConsider updating the summary to reference the exact tool/action name for consistency (“sign_swap” vs “sign swap”).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| --- | |
| "@thirdweb-dev/ai-sdk-provider": patch | |
| --- | |
| Update sign swap action type | |
| --- | |
| "@thirdweb-dev/ai-sdk-provider": minor | |
| --- | |
| Update sign swap action type |
🤖 Prompt for AI Agents
.changeset/quiet-llamas-chew.md around lines 1 to 5: the changeset currently
uses "patch" but the public API changed (SignSwapInput added required fields),
so update the semver bump to "minor" instead of "patch" and adjust the summary
line to reference the exact tool/action name for consistency (use "sign_swap" or
the canonical action identifier instead of "sign swap"); save the file so the
changeset reflects a minor release and consistent naming.

PR-Codex overview
This PR focuses on updating the
sign swapaction type in theai-sdk-providerpackage by refining the data structure to includefrom_tokenandto_tokenfields, enhancing the handling of token-related information in the swap action.Detailed summary
sign swapaction type inprovider.tsto includefrom_tokenandto_token.AgentActionSignSwapDataTokenschema intools.tswith fields:address,chain_id,amount,symbol,decimals, andprice.AgentActionSignSwapDataschema to includefrom_tokenandto_tokenusing the newAgentActionSignSwapDataTokenschema.Summary by CodeRabbit