Repository navigation
feat: standalone tool support - take 2 - #571
Conversation
| * @param otherToolInstances additional tool instances exposing tool methods | ||
| * @return this builder for method chaining | ||
| */ | ||
| Builder tools(Object toolInstance1, Object... otherToolInstances); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Hmm, since we are init an array anyway
tools(Object... toolInstances);
tools(List<Object> toolInstances);is good enough
There was a problem hiding this comment.
Isn't just tools(Object instance1, Object... maybeMore) enough?
There was a problem hiding this comment.
Ok, refactor to the above. Open for other ideas, but I think this is simple enough.
There was a problem hiding this comment.
The one with List can be interesting if user want to build one using some conditionals.
| * @param toolInstances one or more objects exposing tool methods | ||
| * @return this builder for method chaining | ||
| */ | ||
| Builder tools(List<Object> toolInstances); |
There was a problem hiding this comment.
No need for filtering of the concrete tools provided by a tool-object? Maybe not as important as for MCP at least.
There was a problem hiding this comment.
No, I don't think so.
User is in control of this. If they are not happy, they can create wrappes.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
LGTM with tiny suggestion
| * @param toolInstances additional tool instances exposing tool methods | ||
| * @return this builder for method chaining | ||
| */ | ||
| Builder tools(Object... toolInstances); |
There was a problem hiding this comment.
shouldn't it at least be one?
Builder tools(Object toolInstance, Object... moreToolInstances);
There was a problem hiding this comment.
ok, this was perhaps already discussed, and not possible because of the overload with collection
There was a problem hiding this comment.
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.
Refs: https://github.com/lightbend/kalix-runtime/issues/3829