-
Notifications
You must be signed in to change notification settings - Fork 7
feat: improve searchtools #146
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -517,26 +517,21 @@ func (c *UtcpClient) CallTool( | |
| return fn(ctx, args) | ||
| } | ||
|
|
||
| func (c *UtcpClient) SearchTools(query string, limit int) ([]Tool, error) { | ||
| tools, err := c.searchStrategy.SearchTools(context.Background(), query, limit) | ||
| func (c *UtcpClient) SearchTools(providerPrefix string, limit int) ([]Tool, error) { | ||
| all, err := c.toolRepository.GetTools(context.Background()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Convert []*Tool to []Tool if needed | ||
| result := make([]Tool, len(tools)) | ||
| for i, tool := range tools { | ||
| switch t := any(tool).(type) { | ||
| case Tool: | ||
| result[i] = t | ||
| case *Tool: | ||
| result[i] = *t | ||
| default: | ||
| // fallback (shouldn't happen) | ||
| result[i] = Tool{} | ||
| var filtered []Tool | ||
| for _, t := range all { | ||
| if strings.HasPrefix(t.Name, providerPrefix+".") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SearchTools now requires a provider prefix and breaks all existing query-based discovery (e.g., passing empty string) by always returning an error. Prompt for AI agents |
||
| filtered = append(filtered, t) | ||
| } | ||
| } | ||
| return result, nil | ||
| if len(filtered) == 0 { | ||
| return nil, fmt.Errorf("no tools found for provider %q", providerPrefix) | ||
| } | ||
| return filtered, nil | ||
|
Comment on lines
+520
to
+534
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| // ----- variable substitution src ----- | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appending the tool before testing
len(result) >= limitlets SearchTools return a result even whenlimit <= 0, breaking the limit contract for zero/negative requests.Prompt for AI agents