Repository navigation
fix: enforce tool name uniqueness - #592
Conversation
| if (toolAnno.name() == null || toolAnno.name().isBlank) { | ||
| // if the annotation does not specify a name, | ||
| // we use the name passed to this method plus the sanitized class name | ||
| method.getDeclaringClass.getSimpleName + "_" + resolvedName |
There was a problem hiding this comment.
For now, adding only the simple name + resolved name.
I tried to use the full qualified class name, but LC4J is quite restricted.
First it only allows alphanumeric, dashes and underscores. This is easy to solve.
But it also limits the name to 64 chars and this will require us to start to trim the name.
Using simpleName + resolvedName must cover most cases, but if user has to class with same name in different packages and having same method names, they will clash.
I need to add a check for that. If we don't, the last added method will shadow the first because we are using a Map(methodName -> Method).
Maybe it's a far fetch case, but better to simply make it fail.
| .filter(m => m.hasAnnotation[FunctionTool]) | ||
| .filter(m => m.isPublic || allowNonPublic) | ||
| // tool methods in agent don't need to be public | ||
| .filter(m => m.isPublic || isAgent(cls)) |
There was a problem hiding this comment.
I wonder if it isn't better so simply allow private methods for all kinds of classes.
I was checking LC4J and they accept private methods in tools.
The fact that we allow for Agents, but not for other classes might create confusion.
Our rational makes sense, IMO. The agent has 'access' to its private methods. On the other hand, the difference in behavior might be confusing.
There was a problem hiding this comment.
I think that agent being able to use its own private methods but not private methods of other classes (external tools) is what is most reasonable ("the path of least astonishment")
No description provided.