Skip to content

feat: standalone tool support - take 2 - #571

Merged
octonato merged 3 commits into
agent-devfrom
octonato/standalone-tool-support-take-2
Jun 13, 2025
Merged

octonato merged 3 commits into
agent-devfrom
octonato/standalone-tool-support-take-2

Conversation

@octonato

@octonato octonato commented Jun 13, 2025 •

Copy link
Copy Markdown
Contributor

* @param otherToolInstances additional tool instances exposing tool methods
* @return this builder for method chaining
*/
Builder tools(Object toolInstance1, Object... otherToolInstances);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was (I am) in doubt about how many variants we should provide here.

tools(Object toolInstance)
tools(Object toolInstance1, Object toolInstance2)
tools(Object toolInstance1, Object toolInstance2, Object... otherToolInstances)

At the end the reason why I chose for

tools(Object toolInstance1,  Object... otherToolInstances);
tools(List<Object> toolInstances);

is more related with easy discovery and javadoc simplification.

The extra price to pay for array allocation might be negligible given the fact that we are about to make a call to an LLM.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, since we are init an array anyway

tools(Object... toolInstances);
tools(List<Object> toolInstances);

is good enough

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't just tools(Object instance1, Object... maybeMore) enough?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, refactor to the above. Open for other ideas, but I think this is simple enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The one with List can be interesting if user want to build one using some conditionals.

@johanandren johanandren left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

* @param toolInstances one or more objects exposing tool methods
* @return this builder for method chaining
*/
Builder tools(List<Object> toolInstances);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need for filtering of the concrete tools provided by a tool-object? Maybe not as important as for MCP at least.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, I don't think so.
User is in control of this. If they are not happy, they can create wrappes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wonder now if filtering for MCP is also that important.

I think the whole idea of MCP is that you should not care what are the methods, they are discovered at runtime and they may change if the MCP server changes.

When we filter it means that we know beforehand which methods are there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It definitely is interesting, and is present in other frameworks/libs I've looked at.

For MCP example: I want to give the LLM access to inspect issue and pull request details but not do pull requests or create issues or a ton of other things the github mcp server can do. Even though a name based filter is brittle it is better than nothing there.

Possible related here would be a library shared between services with some tool class, but where you really only want to give the agent access to one or a few of them.

@efgpinto efgpinto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with tiny suggestion

@octonato
octonato merged commit 626e7b5 into agent-dev Jun 13, 2025
@octonato
octonato deleted the octonato/standalone-tool-support-take-2 branch June 13, 2025 11:22
* @param toolInstances additional tool instances exposing tool methods
* @return this builder for method chaining
*/
Builder tools(Object... toolInstances);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't it at least be one?

Builder tools(Object toolInstance, Object... moreToolInstances);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok, this was perhaps already discussed, and not possible because of the overload with collection

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, you are right. Better to enforce that at least one must be passed.
I had it at first and it was not conflicting with the list variation.

I first started with:

Builder tools(Object toolInstance);
Builder tools(Object toolInstance1, Object toolInstance2);
Builder tools(Object toolInstance1, Object toolInstance2, Object... moreToolInstances);

Then I moved to just because I thought it was good enough.

Builder tools(Object toolInstance1, Object... moreToolInstances);

Then, since we are already allocating an array, I thought that we could have just one method with varargs.

Anyway, I will give it another pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants