8000 Made withTool and removeTool methods more flexible by MaestroError · Pull Request #28 · MaestroError/LarAgent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Made withTool and removeTool methods more flexible #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 16, 2025

Conversation

MaestroError
Copy link
Owner
@MaestroError MaestroError commented May 16, 2025

This PR improves the flexibility and reliability of tool management within the agent system and refines related tests. The changes address initialisation issues, enhance type safety, and ensure robust handling of tool instances and class references.

Key Change is flexibility in the tools management for an agent.

Now you can add a tool at runtime using

  1. With newly created tool object
$tool = Tool::create('test_tool', 'Test tool')->setCallback(fn () => 'test');
$agent->withTool($tool);
  1. With the predefined tool class
$agent->withTool(WeatherTool::class);

And you can remove tools on runtime:

  1. With tool name
// Remove tool by name
$agent->removeTool('get_current_weather');
  1. With the tool object
$tool = Tool::create('test_tool', 'Test tool')->setCallback(fn () => 'test');
$agent->withTool($tool);
if (!$needsTool) {
    $agent->removeTool($tool);
}
  1. With the tool class
$agent->removeTool(WeatherTool::class);

Testing

All relevant tests in AgentTest.php and related suites continue to pass, confirming that tool management works as expected for both class references and direct instances.

@MaestroError MaestroError added the enhancement New feature or request label May 16, 2025
@MaestroError MaestroError merged commit a1d8e51 into main May 16, 2025
@MaestroError MaestroError deleted the tool-management-enhancement branch May 25, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0