Skip to content

Conversation

@dylan-labs
Copy link

@dylan-labs dylan-labs commented Jan 12, 2026

Title:
feat(tool): add return_direct feature for tool functions

Body:

Summary

  • Add return_direct parameter that allows tool functions to return their output directly to the user without further LLM processing
  • When return_direct=True, the agent stops the reasoning-acting loop immediately after tool execution

Changes

  • Add return_direct field to ToolResponse class
  • Add return_direct field to RegisteredToolFunction
  • Add return_direct parameter to register_tool_function()
  • Add return_direct parameter to register_mcp_client()
  • Modify ReActAgent._acting() and reply() to handle return_direct logic
  • Add example and documentation in examples/functionality/return_direct/

Usage

# Method 1: Set at registration time
toolkit.register_tool_function(
    get_weather,
    return_direct=True,
)

# Method 2: Set dynamically in ToolResponse
def my_tool(query: str) -> ToolResponse:
    return ToolResponse(
        content=[TextBlock(type="text", text="result")],
        return_direct=True,
    )

Closes #1077

Add `return_direct` parameter that allows tool functions to return
their output directly to the user without further LLM processing.
This stops the reasoning-acting loop immediately after tool execution.

Changes:
- Add `return_direct` field to ToolResponse class
- Add `return_direct` field to RegisteredToolFunction
- Add `return_direct` parameter to register_tool_function()
- Add `return_direct` parameter to register_mcp_client()
- Modify ReActAgent._acting() and reply() to handle return_direct
- Add example and documentation

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@cla-assistant
Copy link

cla-assistant bot commented Jan 12, 2026

CLA assistant check
All committers have signed the CLA.

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.

ReActAgent在模型调用工具时,如何不进行llm的二次总结

1 participant