Repository navigation
feat: core agent-level suppression for read-only tools - #3615
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to automatically suppress write-capable tools when their associated data source is configured in read-only mode. It defines a new ReadOnlySource interface, updates the tool initialization logic to inspect tool annotations (specifically readOnlyHint), and logs warnings for unannotated tools bound to read-only sources. The reviewer highlighted a potential startup failure when a suppressed tool is explicitly referenced in a configured toolset and IgnoreUnknownTools is false, suggesting that suppressed tools should be automatically filtered out from toolsets during initialization.
efeaaa2 to
c638838
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to automatically suppress write-capable tools when their bound data source is configured in read-only mode, saving the agent's context window. It adds a ReadOnlySource interface, implements suppression logic in initializeTools using reflection, filters suppressed tools from toolsets, and updates the documentation and tests accordingly. Feedback was provided regarding mutating the cfg.ToolsetConfigs map directly in InitializeConfigs, which can cause side effects since maps are reference types in Go; it is recommended to copy the map before modifying it.
9e34992 to
eec1dfb
Compare
cd8b2df to
7ebdddb
Compare
8011f00 to
1b964a1
Compare
9a9af5f to
7930439
Compare
Yuan325
left a comment
There was a problem hiding this comment.
Thank you! Please lmk if you have any questions on the comments
6040eed to
b165fbc
Compare
|
Are we still planning to update this: Enables multi-mode tools (like SQL execution tools) to dynamically report ReadOnlyHint: true and DestructiveHint: false in MCP tool manifests when connected to a read-only source. |
89c827a to
32de615
Compare
As mentioned in this comment, the multi-mode tool dynamic annotation was implemented in |
|
🚀 Cloudflare Preview Ready! 🔎 View Preview: https://pr-3615.toolbox-docs-6xc.pages.dev (Note: Subsequent pushes to this PR will automatically update the preview at this same URL) |
|
🧨 Preview deployments removed. Cloudflare Pages environments for |
Description
This PR introduces core framework support for agent-level tool suppression and dynamic annotations in read-only mode.
When a data source or admin service is configured as
readonly: true, write-capable and destructive tools bound to that source are automatically suppressed from tool registration and pruned from tool groups. This saves valuable LLM agent context window space, eliminates agent confusion by preventing tool hallucination/misuse on read-only resources, and acts as a defense-in-depth layer in conjunction with database-level session locking.Design
sources.SourceInterface Extension:IsReadOnly() boolto thesources.Sourceinterface.IsReadOnly()across all existing data source drivers (50+ sources).readonlyconfiguration support toalloydb-adminandcloud-sql-adminsources.Tool Suppression Protocol:
ShouldSuppress(sources.Source) boolto thetools.Toolinterface.BaseTool, default suppression logic checks if the bound source is in read-only mode and suppresses any tool whoseReadOnlyHintannotation isfalse.ReadOnlyHint == true) and unannotated tools are preserved (with a warning logged for unannotated tools to encourage explicit annotation).postgresexecutesqlandmysqlexecutesqloverrideShouldSuppressto remain enabled because they enforce read-only semantics at the database connection/session level.Server-Level Tool Filtering & Group Pruning:
initializeTools), write-capable tools bound to read-only sources are suppressed and omitted from the server's registered tools map with an informative log.initializeGroups), suppressed tools are cleanly pruned from configured groups while keeping the group intact and preserving standard validation errors for genuinely missing tools.Dynamic Tool Annotations in MCP Manifests:
v20241105,v20250326,v20250618,v20251125,v20260728) to querytool.Manifest(src)dynamically.Cloud SQL PG Vector Assist Annotations:
vectorassistapplyspec,vectorassistdefinespec,vectorassistgeneratequery,vectorassistgetspec,vectorassistimprovequeryrecall,vectorassistlistspecs,vectorassistmodifyspec) with annotations (ReadOnlyAnnotationsvsDestructiveAnnotations) and support for custom YAML annotations.PR Checklist