Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Sep 4, 2025


PR-Codex overview

This PR focuses on updating the sign swap action type in the ai-sdk-provider package by refining the data structure to include from_token and to_token fields, enhancing the handling of token-related information in the swap action.

Detailed summary

  • Updated the sign swap action type in provider.ts to include from_token and to_token.
  • Defined AgentActionSignSwapDataToken schema in tools.ts with fields: address, chain_id, amount, symbol, decimals, and price.
  • Updated AgentActionSignSwapData schema to include from_token and to_token using the new AgentActionSignSwapDataToken schema.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features
    • Enhanced sign_swap action to include source and destination token details (from_token/to_token), providing address, chain ID, symbol, decimals, amount, and price for each token. Enables richer context and validation during swaps.
  • Chores
    • Published a patch release for the AI SDK provider reflecting the updated sign_swap action type.

@vercel
Copy link

vercel bot commented Sep 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Sep 4, 2025 10:31pm
nebula Ready Ready Preview Comment Sep 4, 2025 10:31pm
thirdweb_playground Ready Ready Preview Comment Sep 4, 2025 10:31pm
thirdweb-www Ready Ready Preview Comment Sep 4, 2025 10:31pm
wallet-ui Ready Ready Preview Comment Sep 4, 2025 10:31pm

@changeset-bot
Copy link

changeset-bot bot commented Sep 4, 2025

🦋 Changeset detected

Latest commit: 38831fc

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

This PR includes changesets to release 1 package
Name Type
@thirdweb-dev/ai-sdk-provider 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary of changes
AI SDK Provider — sign_swap schema update
packages/ai-sdk-provider/src/tools.ts, packages/ai-sdk-provider/src/provider.ts
tools.ts: Introduces AgentActionSignSwapDataToken schema and adds from_token and to_token to AgentActionSignSwapData. provider.ts: Populates and appends from_token and to_token to the SignSwapInput when handling sign_swap. Exported SignSwapInput now includes these fields.
Release metadata
.changeset/quiet-llamas-chew.md
Adds patch release note for @thirdweb-dev/ai-sdk-provider describing the sign swap action type update.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _AI_SDK_Provider_Update_sign_swap_action_type_with_token_fields

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@joaquim-verges joaquim-verges marked this pull request as ready for review September 4, 2025 22:16
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.53%. Comparing base (aadaf20) to head (38831fc).
⚠️ Report is 19 commits behind head on main.

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     
Flag Coverage Δ
packages 56.53% <ø> (+<0.01%) ⬆️
see 14 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.01 KB (0%) 1.3 s (0%) 2.7 s (+1.86% 🔺) 4 s
thirdweb (cjs) 357.32 KB (0%) 7.2 s (0%) 19.1 s (-0.28% 🔽) 26.3 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 254 ms (+83.19% 🔺) 369 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 156 ms (+232.89% 🔺) 166 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 370 ms (+24.11% 🔺) 753 ms

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 fields

Small 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-calls

The 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.

📥 Commits

Reviewing files that changed from the base of the PR and between dc57b85 and 38831fc.

📒 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 in packages/* 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 @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless 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 @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless 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.ts
  • packages/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.ts
  • packages/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: explicit from_token/to_token shape

Schema 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.

Comment on lines +1 to +5
---
"@thirdweb-dev/ai-sdk-provider": patch
---

Update sign swap action type
Copy link
Contributor

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": minor

Consider 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.

Suggested change
---
"@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants