Description
When using Fantasy on the server side, there is currently no convenient way to define a tool that should be executed on the client side.
The issue is that when creating a tool via NewAgentTool, the return value of the execution function is always treated as a tool result. However, for client-side tools, we typically don't want to return a tool result from the server at all — we simply want to interrupt the current turn and hand control back to the client so it can execute the tool locally.
It would be best to introduce a clear convention for the execution function’s return value, so this situation can be handled directly inside the tool execution function itself. For example, returning a specific sentinel value (such as YieldToClient) could signal that the tool should be executed on the client and the current turn should be interrupted.
Description
When using Fantasy on the server side, there is currently no convenient way to define a tool that should be executed on the client side.
The issue is that when creating a tool via NewAgentTool, the return value of the execution function is always treated as a tool result. However, for client-side tools, we typically don't want to return a tool result from the server at all — we simply want to interrupt the current turn and hand control back to the client so it can execute the tool locally.
It would be best to introduce a clear convention for the execution function’s return value, so this situation can be handled directly inside the tool execution function itself. For example, returning a specific sentinel value (such as YieldToClient) could signal that the tool should be executed on the client and the current turn should be interrupted.