Skip to content

Conversation

@dmackdev
Copy link
Contributor

@dmackdev dmackdev commented Aug 15, 2025

Closes #696.

  • Implements Tool for Agent, so that an Agent can be added as a Tool to be used by another Agent.
  • Adds new example agent_with_agent_tool to demonstrate an Agent using another Agent as a Tool.


async fn definition(&self, _prompt: String) -> ToolDefinition {
ToolDefinition {
name: <Self as Tool>::name(self),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is distinguish between the Agent::name method and the Tool::name trait method. The Tool::name trait method implementation here returns a valid Tool name.
This is important because the Agent::name method could return an invalid Tool name - either an invalid one set by the user, or, if not set, the default name "Unnamed Agent" (which is invalid due to the whitespace).

@dmackdev dmackdev marked this pull request as ready for review August 15, 2025 14:05
@dmackdev
Copy link
Contributor Author

dmackdev commented Aug 15, 2025

@joshua-mo-143 I have tested this locally by modifying the agent_with_tools example to introduce an "Agent-Tool using Agent" that uses the existing "Calculator Agent" as a Tool. I can see from the logs that the "Agent-Tool using Agent" calls the "Calculator Agent", which in turn calls the Subtract tool.

Would you like me to add/amend an example to demonstrate this?

@joshua-mo-143
Copy link
Contributor

@joshua-mo-143 I have tested this locally by modifying the agent_with_tools example to introduce an "Agent-Tool using Agent" that uses the existing "Calculator Agent" as a Tool. I can see from the logs that the "Agent-Tool using Agent" calls the "Calculator Agent", which in turn calls the Subtract tool.

Would you like me to add/amend an example to demonstrate this?

Yeah that would be great actually

Copy link
Contributor

@joshua-mo-143 joshua-mo-143 left a comment

Choose a reason for hiding this comment

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

One change required but that's basically it

};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Use schemars::JsonSchema (the derive macro) here - it's much easier to convert into a JSON schema rather than using fragile JSON

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Done.

@dmackdev dmackdev requested a review from joshua-mo-143 August 16, 2025 08:30
Copy link
Contributor

@joshua-mo-143 joshua-mo-143 left a comment

Choose a reason for hiding this comment

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

Sorry missed something last review - final change and then we'll merge!

Copy link
Contributor

@joshua-mo-143 joshua-mo-143 left a comment

Choose a reason for hiding this comment

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

lgtm

@joshua-mo-143 joshua-mo-143 merged commit 0b483cc into 0xPlaygrounds:main Aug 17, 2025
5 checks passed
@github-actions github-actions bot mentioned this pull request Aug 17, 2025
@dmackdev dmackdev deleted the feat/impl-tool-for-agent branch August 18, 2025 12:06
@0xMochan
Copy link
Contributor

Nice, i wasn't able to finish my branch for this. glad it got in there!

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.

feat: impl Tool for Agent<M>

3 participants