payman.tool() puts the served definition in the array; handleToolUse() runs the action when the model calls it.
Node
The two calls
payman.tool() is synchronous. It returns the definition the platform serves: name payman_money_task, one required input field, instruction, and one optional one, provider. Never transcribe the definition into your code; the SDK caches the served copy and ships a bundled snapshot for the first call.
payman.toolDefinitionVersion() names the contract date you are running against, and await payman.doctor() reports drift.
handleToolUse() takes the block’s id and input, runs the action, and resolves a ToolTurn with two fields:
Push
toolResult back to the model unchanged. Render from ui: switch on kind and show the connect or approval button exactly as you would after run(). toolResult structurally cannot carry connectUrl, approvalUrl, or a ref; URLs exist only on ui.
Progress while it runs
handleToolUse() accepts the same options as run(). Passing onEvent switches the call to the streaming route and delivers frames while the result is still pending.
Each progress frame carries a phase (started, completed, waiting) and a label written for the customer. Render the label and replace it on the next frame rather than stacking lines.
What the schema takes
Two fields, and nothing else. No amount, no payee, no credential, no session id.
Pass the request as the customer said it. Do not split it into structured fields, and do not rule requests out by institution type in your prompt: capability varies with what the customer connected, so call the tool and let the result answer.
The served description already carries the ground rules for relaying and attributing answers, so they arrive with the tool rather than depending on your prompt.
When the Wallet asks back
A customer can connect several accounts. Two statuses are the Wallet asking, not failing:
The served description tells the model both, so this needs nothing from your prompt. On your side the same value arrives on
ui.agentStatus. See the Wallet.
Connecting an account is not a money task. If the model calls this tool to link or remove one, the platform hands back the link to the customer’s Payman page instead.
