fix: add is_available and extract_params to MongoDB, ClickHouse, Kafka, and CloudWatch tools#732
Conversation
…a, and CloudWatch tools (Tracer-Cloud#730) 10 tools defaulted to _always_available, causing them to appear in the planner for every pipeline regardless of context. The LLM would select them, they would fail with TypeError on missing required arguments, and the agent wasted investigation loops on dead-end actions. - Add mongodb_is_available + mongodb_extract_params to integrations/mongodb.py - Add clickhouse_is_available + clickhouse_extract_params to integrations/clickhouse.py - Add kafka_is_available + kafka_extract_params to integrations/kafka.py - Add cloudwatch_is_available to tools/utils/availability.py - Wire is_available + extract_params into all 10 affected tool decorators extract_params ensures credentials are auto-filled from resolved integrations so the LLM never needs to supply connection strings. ClickHouse and Kafka source blocks in detect_sources.py are tracked separately; the helpers are ready to activate once that wiring lands.
Greptile SummaryThis PR fixes a planner-pollution bug where 10 tools (MongoDB ×5, ClickHouse ×2, Kafka ×2, CloudWatch ×1) defaulted to Key changes:
Confidence Score: 4/5Safe to merge; all three previously flagged issues are resolved and the implementation is consistent with established patterns. The core bug is properly fixed.
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Planner: filter tools via is_available] --> B{sources dict}
B --> C[sources.get 'mongodb']
C --> D{connection_verified?}
D -- No --> E[Tools hidden from planner]
D -- Yes --> F{database present?}
F -- No --> G[ServerStatus / CurrentOps / ReplicaStatus visible]
F -- Yes --> H[All 5 MongoDB tools visible]
B --> I[sources.get 'clickhouse']
I --> J{connection_verified?\ndetect_sources wiring pending}
J -- No --> K[Tools hidden until follow-up]
J -- Yes --> L[ClickHouse tools visible]
B --> M[sources.get 'kafka']
M --> N{connection_verified?\ndetect_sources wiring pending}
N -- No --> O[Tools hidden until follow-up]
N -- Yes --> P[Kafka tools visible]
B --> Q[sources.get 'cloudwatch']
Q -- key absent --> R[Tool hidden]
Q -- key present\nlog_group in annotations --> S[CloudWatchBatchMetricsTool visible\nLLM supplies job_queue]
Reviews (3): Last reviewed commit: "fix: cloudwatch_is_available should chec..." | Re-trigger Greptile |
…tion_verified and add database guard - mongodb_is_available now checks connection_verified (consistent with clickhouse_is_available and kafka_is_available; connection_verified is set by detect_sources when MongoDB is configured and validated) - Add mongodb_database_is_available for tools that require a database name (MongoDBProfilerTool, MongoDBCollectionStatsTool); without it those tools would appear in the planner and return an error when no database is configured, repeating the original bug in a narrower scope
|
@greptile-apps re-review |
…nection_verified detect_sources.py populates sources["cloudwatch"] from alert annotations (cloudwatch_log_group) but never writes connection_verified — CloudWatch uses ambient IAM auth, not an API key. Checking connection_verified caused the tool to be permanently hidden even when CloudWatch context was present.
|
@greptile-apps re-review |
VaibhavUpreti
left a comment
There was a problem hiding this comment.
awesome @devankitjuneja! 🚀 Good catch with the bug
Fixes #730
Describe the changes you have made in this PR -
10 tools defaulted to
_always_available, causing them to appear in the planner for every investigation regardless of pipeline context. In pipelines likerds-postgres-synthetic(Grafana-only), the LLM would select MongoDB, ClickHouse, Kafka, and CloudWatch tools, they would fail withTypeError: missing required argument, and the agent wasted investigation loops on dead-end actions.Root cause:
BaseTool.is_available()returnsTrueby default. Therequires=[...]field on@toolis documentation-only — not wired to the availability check.Changes:
mongodb_is_available+mongodb_extract_paramstoapp/integrations/mongodb.pyclickhouse_is_available+clickhouse_extract_paramstoapp/integrations/clickhouse.pykafka_is_available+kafka_extract_paramstoapp/integrations/kafka.pycloudwatch_is_availabletoapp/tools/utils/availability.py(noextract_params— CloudWatch uses IAM auth,job_queueis alert-specific)is_available+extract_paramsinto all 10 affected tool decoratorsextract_paramsfollows the established PostgreSQL/MongoDB pattern — credentials are auto-filled from resolved integrations so the LLM never needs to supplyconnection_string,host, orbootstrap_servers. ClickHouse and Kafkadetect_sources.pywiring is tracked in a follow-up issue; the helpers are ready to activate once that lands.Screenshots of the UI changes (If any) -
N/A
Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
The planner filters tools via
action.is_available(available_sources)before passing them to the LLM. Tools without a customis_availablealways pass this filter. The fix adds named helper functions in each integration module (matching the pattern already used by PostgreSQL and MongoDB tools) and wires them into the@tooldecorator.extract_paramsauto-fills connection credentials fromavailable_sourcesso the LLM receives only alert-specific parameters it can reason about.Checklist before requesting a review
Note: Please check Allow edits from maintainers if you would like us to assist in the PR.