Repository navigation
MCP budget: get_pg_io_trend's default call now fits the 32 KB budget (#4198) - #4263
Merged
Merged
Conversation
…budget (#4198) The tool's point is the widest in the trend family (28 numeric/boolean fields, no text to truncate), so the shared 200-point auto-sizing target every other trend tool leaves its default to put a default 24-hour call's 10-minute bucketing at 145 points, measured 56-59 KB on a live fixture - well over McpResponseBudget.DefaultBytes (32 KB). Gives get_pg_io_trend its own, narrower MCP auto-sizing target (70 points, TrendBuckets.PgIoMcpAutoPoints) via a new TrendBudget.Mcp(autoPoints, maxPoints) overload, so the default call lands on a 30-minute bucket instead: measured 48 points, 21.5 KB. An explicit bucket_minutes is unaffected - it still reaches the read's own 650-point cap. The web viewer's /api/read mirror keeps TrendBudget.Chart, untouched. New live test: Darling.Tests.PgIoTrendDefaultBudgetLiveTests, seeding one (backend_type, context) pair at one-minute cadence and measuring the literal default call's UTF-8 bytes. Fails on the old shape (60,456 bytes measured), passes on the new one (22,016 bytes measured). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TszxYhJJbTEh4LrZ56NYo3
erikdarlingdata
marked this pull request as ready for review
September 25, 2026 07:59
erikdarlingdata
enabled auto-merge (squash)
September 25, 2026 08:06
This was referenced Sep 25, 2026
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.
Part of #4198.
Why
get_pg_io_trend's point is the widest in the trend family. It has 28 numeric/boolean fields: read/write/extendrates, cache-hit ratio, per-op latency, several tracking flags. There is no text field to truncate.
Every trend tool's default (auto-sized) call shares one 200-point target,
TrendBuckets.McpPointBudget, when thecaller leaves
bucket_minutesto the tool. That fits most of the family. Butget_pg_io_trend's wide point putsa default 24-hour, one-series call's 10-minute bucketing at 145 points. That measured 56-59 KB. This held both on
a production store and on this PR's own live fixture. It is well over the shared
McpResponseBudget.DefaultBytestarget of 32 KB (#4198).
What changes
PerformanceMonitor.Common/Mcp/TrendBuckets.cs: a newTrendBudget.Mcp(autoPoints, maxPoints)overload.Also
TrendBuckets.PgIoMcpAutoPoints(70),get_pg_io_trend's own, narrower MCP auto-sizing target. Its doccomment records the measured bytes/point and the window sweep it was checked against. This keeps Trend tools return every raw point: get_file_io_trend sends 12,451 points / 1.4 MB for one server at defaults, more than an LLM client's context #3897's
design intact: the read's own cap on an explicit
bucket_minutes,PgIoMaxPoints(650), is untouched. So isthe one-arg
TrendBudget.Mcp(maxPoints)factory every other trend tool uses.Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingMcpPgTrendTools.cs:get_pg_io_trend's MCP entry pointnow passes
TrendBudget.Mcp(PgIoMcpAutoPoints, PgIoMaxPoints)instead ofTrendBudget.Mcp(PgIoMaxPoints)./api/readmirror keeps calling the internal overload withTrendBudget.Chartdirectly. ThisPR does not touch the chart.
windows get correspondingly wider, still auto-sized, ladder-picked buckets too.
Darling/Darling.Tests/McpToolsListBudget/DarlingMcpPgTrendTools.txtneeded no edit.
Darling/Darling.Tests/PgIoTrendDefaultBudgetLiveTests.cs. It seeds one (backend_type, context) pairat one-minute cadence for just over a day. It calls the tool with every argument defaulted, the literal default
call, and asserts the UTF-8 byte count stays under
McpResponseBudget.DefaultBytes. It fails on the pre-fixshape and passes on the fixed one. A second assertion in the same test confirms an explicit
bucket_minutesstill returns the full window's points, unaffected by the narrower default target.
Test plan
Rig: reused the stopped
rig-tarig (port 55976, already UTC). Dropped and recreateddarlingtestandprobefirst, since a prior lane had left data there.
Measured bytes,
get_pg_io_trend, default call (24h, one series), on this PR's live fixture:production-store measurement in the brief.
bucket_minutesis unaffected.TrendPayloadBudgetLiveTests' cap-side case is 168h at thenarrowest width the 650-point cap admits. It still measures 631 points / 248.6 KB, same as before this
change.
get_pg_*tool, has no Lite surface.Skipped the common brief's Lite steps and the Lite.Tests run, per this lane's own brief.
Targeted classes (rig,
DARLING_TEST_PGagainstrig-ta):PgIoTrendDefaultBudgetLiveTests(new): 1/1 passed after the fix.TrendPayloadBudgetLiveTests: passed clean on the run kept as final. Two earlier runs each failed once, ona different tool's line each time:
get_file_io_trend, thenget_pg_io_trend. Both failures were aconnection-level "Exception while reading from stream", not a size assertion. This fixture seeds a
600-file, 300-tenant-database series, and that heavy seeding looks like the real cause, not a
get_pg_io_trend-specific defect. A clean rerun on a freshly recreateddarlingtestpassed all tools,including
get_pg_io_trendat every window.TrendBucketingLiveTests: 6/6 passed. All calls there use an explicitbucket_minutes, so this changecannot affect them, and the pass confirms that.
TrendBucketsTests(unit, no rig): 37/37 passed.Full suite, once, after merging
origin/dev(clean merge) and recreatingdarlingtest:Darling.Tests: Total 13,856, Errors 0, Failed 2, Skipped 47 (expected env-gated fixtures), Not Run 1,625.8s. Build: 0 Warning(s), 0 Error(s).
ServerListAndSummaryPlanShapeTests.TheShippedReads_TouchFarFewerChunks_AndReturnTheSame NewestCollection_AgainstDevPostgresandCaptureDownChunkOrderTests.TheShippedRead_ExecutesOnlyTheNewestChunk_ AndTheNewestRunDecides_AgainstDevPostgres. Both are TimescaleDB chunk-exclusion EXPLAIN-plan-shape assertionson
collect.collection_log. That is a subsystem this PR's diff does not touch: server-list/summary reads andcollection-log chunk pruning, not trend reads. I reproduced both deterministically alone on
rig-ta. They arepre-existing: dev's own latest CI Build run (36108125880, 2026-09-25T07:32:06Z) shows 0 failures across all
three Darling PG test shards, 13,855 tests total. The most likely cause is a TimescaleDB build or version
difference between this reused rig and CI's freshly provisioned one. It sits outside this lane's
get_pg_io_trendbrief, in a subsystem I have no context on. I am flagging it for the coordinator instead offixing it here.
CHANGELOG entry
SECTION: Fixed
ENTRY:
measured 56-59 KB. Its point is the widest in the trend family, over the 32 KB budget every MCP read
tool's defaults now target (MCP read tools have no default response-size budget: at default arguments 12 tools return >50 KB and 3 return >100 KB for one server, more than an agent client's per-result cap #4198). The default call now buckets to 30 minutes instead of 10, measuring
under 22 KB. An explicit bucket_minutes argument is unaffected and still reaches the tool's existing cap.
REF:
[MCP budget: get_pg_io_trend's default call now fits the 32 KB budget (#4198) #4263]: MCP budget: get_pg_io_trend's default call now fits the 32 KB budget (#4198) #4263
Generated with Claude Code
https://claude.ai/code/session_01TszxYhJJbTEh4LrZ56NYo3