Repository navigation
π fix(adminmcp): the text cap cuts the largest list, not the longest - #16887
hivecommons-hive[bot] merged 1 commit into
Conversation
A result over the 256 KiB cap had its longest top-level list halved first, by entry count. A long list of small entries frees almost nothing, so on a 15-agent, 12-repo hive fleet_status (350 KB) lost half of acmmPackAgents, cadenceMatrix and configuredAgents for a few KB, besides the cuts to agents and repos that were needed. shrinkLists now ranks lists by encoded size and breaks ties by name, so small lists stay whole and one result is cut the same way on every call (ties were decided by map order). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Looks correct to me. Read src/pkg/adminmcp/result_cap.go at base and with the change: the loop, maxShrinkRounds, the <field>_truncated / text_cap_truncated_fields / original_lengths disclosure and the final envelope size check are unchanged; only the pick moves from entry count to json.Marshal size, with sizes[key] refreshed after each halving and the key dropped once the list is empty (same as the old len(items) > 0 filter). The k < best tie-break removes the Go map-order nondeterminism. src/docs/design/admin-mcp.md is updated to match.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
Summary
When an admin MCP result is over the 256 KiB text cap, the cap shortens lists to make it fit. It picked which list to shorten by how many entries it had, not by how big it was. Small lists were cut for no gain, and the same result could be cut differently on two calls. This PR ranks lists by size and makes the cut repeatable.
What an operator saw
fleet_statuson a hive with 15 agents and 12 repos is about 350 KB. It came back as:agentsreposacmmPackAgentscadenceMatrixconfiguredAgentsCutting
agentsandreposwas enough to fit. The other three lost half their entries because they had more entries thanrepos, and the model was left with half the cadence table for nothing.What changes
<field>_truncated,_admin_mcp.text_cap_truncated_fields,original_lengths) is unchanged.This does not make an over-cap
fleet_statuswhole:agentsandreposare still halved when they are what is too big. It stops the cap from removing data that did not need to go.Files
src/pkg/adminmcp/result_cap.go:shrinkListsranks by encoded size (listSizes,largestList).src/pkg/adminmcp/polish_test.go: two new tests.src/docs/design/admin-mcp.md: the "Hard caps" paragraph says how lists are chosen.changelog.d/fixed-admin-mcp-text-cap-largest-list.mdTests
TestTextCapCutsTheLargestListNotTheLongest: one 360 KB list of 12 entries and three small lists of 15; only the big one is cut.TestTextCapCutsEqualListsInAStableOrder: 20 calls give byte-identical output, and the third of three equal lists stays whole.v6without the change (the second with "call 2 truncated the same result differently").go test ./pkg/adminmcp/ ./cmd/hive-admin-mcp/passes;check-docs-citations.pypasses.π€ Generated with Claude Code