Skip to content

πŸ› fix(adminmcp): the text cap cuts the largest list, not the longest - #16887

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/adminmcp-text-cap-largest-list
Nov 6, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/adminmcp-text-cap-largest-list

Conversation

@Danathar

@Danathar Danathar commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

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_status on a hive with 15 agents and 12 repos is about 350 KB. It came back as:

list kept size of the whole list
agents 7 of 15 about 125 KB
repos 6 of 12 about 94 KB
acmmPackAgents 7 of 15 a few KB
cadenceMatrix 7 of 15 about 2 KB
configuredAgents 7 of 15 about 6 KB

Cutting agents and repos was enough to fit. The other three lost half their entries because they had more entries than repos, and the model was left with half the cadence table for nothing.

What changes

  • The list with the most encoded bytes is halved first, then the next largest, until the result fits. A long list of small entries stays whole when cutting it would not help.
  • Lists of equal size are cut in name order. Before, a tie was decided by Go map order, so one result could be truncated differently from call to call.
  • The disclosure (<field>_truncated, _admin_mcp.text_cap_truncated_fields, original_lengths) is unchanged.

This does not make an over-cap fleet_status whole: agents and repos are 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: shrinkLists ranks 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.md

Tests

  • 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.
  • Both fail on v6 without the change (the second with "call 2 truncated the same result differently").
  • go test ./pkg/adminmcp/ ./cmd/hive-admin-mcp/ passes; check-docs-citations.py passes.

πŸ€– Generated with Claude Code

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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 6, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hanthor for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#16894 πŸ› fix(adminmcp): issues_by_band accepts the outside band it reports same files src/docs/design/admin-mcp.md
#16884 ✨ feat(adminmcp): read and act on the Activity monitor; writes run as the verified caller same files src/docs/design/admin-mcp.md

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 77d675a into hivecommons:v6 Nov 6, 2026
72 of 75 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

Evidence bundle `#16887104419f` sha256:7eec652216c4cb6aafe4974a537da5d77eb05243cffab960d413b4e0998e0d18 β€” download from the dashboard or `hivectl review evidence #16887`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant