Skip to content

fix(tools): declare transfer_nft.fromAddress in getToolDefinitions - #113

Merged
portdeveloper merged 1 commit into
portdeveloper:mainfrom
Yash-arch-ui:fix/112-transfer-nft-from-address
Oct 2, 2026
Merged

portdeveloper merged 1 commit into
portdeveloper:mainfrom
Yash-arch-ui:fix/112-transfer-nft-from-address

Conversation

@Yash-arch-ui

Copy link
Copy Markdown
Collaborator

Closes #112

What

getToolDefinitions() hand-writes the tool schemas while systemPrompt() / nativeSystemPrompt() are generated from ACTIONS, and the transfer_nft entry had drifted: the prompt advertises transfer_nft(to, contractAddress, tokenId, fromAddress?) but the schema only declared to, contractAddress, tokenId. With USE_NATIVE_TOOLS defaulting to true, that is the schema the model ships with — so a model following the prose sent an undeclared argument, and a model reading the schema never learned the approval-transfer path exists.

  • src/tools.mjs: add fromAddress to the transfer_nft schema as an optional string property with a description (defaults to the agent's own wallet; set only for a token owned by another address that has approved this account). It stays out of required, matching ACTIONS.optionalArgs and both prompt lines.
  • test/native-tools-no-model.test.mjs: pin the transfer_nft schema (property present, string, not in required), and add a drift check asserting every tool's properties equal ACTIONS.args ∪ optionalArgs and its required equals args minus optionalArgs (account and get_nfts excepted — hasRequiredArgs() lets those run with no arguments). That check is what would have caught this class of bug for all 9 tools, not just this one.

dispatchToolCall() already forwarded fromAddress and runAction already validates it (from #69), so this is schema-only — no behavior change.

Testing

  • Issue repro now prints ['to', 'contractAddress', 'tokenId', 'fromAddress'] with required still ["to","contractAddress","tokenId"].
  • npm test: 539 tests, 531 pass, 8 fail — the same 8 fail on clean main here (empty .env seed / no model env), so no new failures; both new tests pass.
  • Reverting just the src/tools.mjs hunk makes both new tests fail, so they pin the fix.
  • npm run build OK; npm run smoke → SMOKE_OK (v0 path, no model available for native tool-calling locally).

The native tool schema dropped the optional fromAddress that
nativeSystemPrompt() advertises as fromAddress?, so a native-mode model
could either send an undeclared argument or never learn the approval
transfer path exists. Add it as an optional string property (not in
required) and pin both the transfer_nft schema and a generic
ACTIONS-vs-schema drift check so the two surfaces cannot diverge again.
@Yash-arch-ui

Copy link
Copy Markdown
Collaborator Author

@portdeveloper

@portdeveloper portdeveloper left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

lgtm, thanks

@portdeveloper
portdeveloper merged commit b0fe608 into portdeveloper:main Oct 2, 2026
3 checks passed
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.

getToolDefinitions omits transfer_nft.fromAddress, so native tool-calling cannot express it

2 participants