Repository navigation
PR #62 follow-up 14: signal get_trace_activity truncation at 500 rows - #71
Merged
Merged
Conversation
…ilently get_trace_activity ordered rows by bucket time and capped them at 500, both in the generated SQL and in the generic tool wrapper. With high groupBy cardinality (e.g. 20 services x 60 buckets) the newest buckets were cut off with no indication, which reads as traffic dropping to zero. The generated query now fetches MAX_TOOL_ROWS + 1 rows and runs as-is after validation (it already carries its own LIMIT), so the tool can return at most 500 rows plus a `truncated` flag. The returned `query` is now exactly the SQL that ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fix/pr62-14-trace-activity-truncation # Conflicts: # docs/tool-api.md # src/tool_executor.rs
… fix/pr62-14-trace-activity-truncation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #62 (base
upstream/tool-catalog-1831). Retarget tomainafter #62 merges.Problem
get_trace_activityorders rows by bucket time, oldest first, and capped them at 500, both in the generated SQL (ORDER BY 1 LIMIT 500) and in the genericbounded_tool_sqlwrapper. WhengroupBycardinality is high (e.g. 20 services × 60 buckets ≈ 1200 rows), the newest buckets were dropped and nothing in the response said so. A caller, especially an LLM, reads that as traffic falling to zero.Fix
LIMIT MAX_TOOL_ROWS + 1(501).validate_tool_sql, the query runs as-is. It already carries its own LIMIT, and the 500-row wrapper would hide the probe row. As a side effect, the returnedqueryis now exactly the SQL that ran.truncate_trace_activity_rowscaps the rows at 500 and returns whether any were dropped. The response gains"truncated": bool.docs/tool-api.mddocuments the ordering,LIMIT 501,truncated, and how to get the full series (reducebucketCount,groupByor the time range).Tests
trace_activity_signals_truncation_past_the_row_limit: a DataFusion fixture with 20 services × 60 one-minute buckets (1200 groups×buckets) runs the generated SQL the way the tool does. It assertstruncated == true, 500 rows, and that the last kept bucket is00:24, i.e. the newest buckets are the ones dropped. It also checks that an ungrouped 60-row series is not flagged, plus the exactly-500 andrecords-object edge cases. With the oldLIMIT 500this test fails by construction: at most 500 rows come back, sotruncate_trace_activity_rowsreturnsfalse. (A local negative-control build was OOM-killed under machine load, so this was not observed empirically.)cargo test --lib tool_: 39 passed.cargo fmt --checkis clean, andcargo clippy --all-targetsadds no warnings in touched files.Upstream fidelity
This is a small divergence from upstream 32979cb in
src/tool_executor.rs(the query LIMIT, one helper, one response field) plus docs. It's additive for callers (a newtruncatedfield), and the same fix is drafted for upstream on the review wiki page. Possible overlap: the item 04 docs wording, and items 15/21 in the same function.🤖 Generated with Claude Code