feat: add query_logs tool for custom log queries (CI mirror of #333) - #341
feat: add query_logs tool for custom log queries (CI mirror of #333)#341jordienr wants to merge 12 commits into
Conversation
Coverage Report for CI Build 30825182795Warning No base build found for commit Coverage: 96.315%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
|
Structured review done against this head (c1bdc7f, same SHA as #333, so everything transfers). CI green here confirms the #333 failures were fork-secrets only. The One blocker before the checkmark: the types regen drops fields that exist on main. Optional while you're in there: |
Removes content that depends on supabase/agent-skills#112 and supabase/mcp#341 before those PRs have merged: - Delete ai-agents.mdx (new page documenting query_logs / get_logs / skill) - Remove MCP tip admonition from debugging.mdx - Remove telemetry-ai ContentListings panel from overview - Remove telemetryAI export from telemetry.data.ts - Remove telemetryAI from content-listings index - Remove "AI & automation" nav group from NavigationMenu.constants.ts These changes move to docs/telemetry-mcp-tools which targets this branch as its base and will not merge until the two external PRs land. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a query_logs debugging tool that runs a custom read-only ClickHouse SQL query against a project's unified logs stream, for cases where the get_logs service presets are too coarse. Reuses the existing analytics logs endpoint and validates that queries are SELECT/WITH only.
- add function_edge_logs to the sql source-hint list so models can reach edge function invocation logs - require a non-empty sql query (.min(1)), matching execute_sql - add execution tests for query_logs: sql passthrough + timestamp defaulting, custom window forwarding, and empty-query rejection
- mark get_logs as deprecated on hosted projects in favour of query_logs, while keeping it as the path for CLI/self-hosted - document that query_logs (ClickHouse) is hosted-only and will not work on CLI/self-hosted yet
The permissive mention of iso_timestamp_start/iso_timestamp_end wasn't steering model behaviour, so narrow time-range questions silently inherited the 24h default and over-counted. Make it a directive instruction in both get_logs and query_logs, matching the mechanism that flipped tool selection.
The description promises iso_timestamp_start defaults to 24h before the end, but the handler always computed start from now(), so supplying only iso_timestamp_end produced an inverted/empty window. Derive the end first (supplied or now), then default start to end - 24h, shared by get_logs and query_logs.
resolveLogWindow now rejects a malformed iso_timestamp_start/end with a clear error instead of throwing a raw "Invalid time value", and rejects a start at or after the end. Also rebases onto main to pick up the regenerated management API types.
c1bdc7f to
09e521e
Compare
Both tools currently ship an identical description to every client regardless of platform (hosted vs local/self-hosted), so labeling get_logs "Deprecated" risked a client universally hiding or deprioritizing it, which would break self-hosted users since get_logs is their only working logs tool. Reframe as environment-scoped preference (prefer query_logs on hosted, use get_logs on local/self-hosted) instead of an unqualified deprecation.
Same changes as #333, pushed to a branch on the repo (not a fork) so the e2e tests run with CI secrets — #333's
testcheck can't pass from the fork because forks don't receive secrets.Do not merge this in place of #333 unless we decide to; it exists to verify the e2e suite goes green with secrets available. #333 remains the review PR.
Identical head commit as #333 (
c1bdc7f).