#1143·honcho

[Bug] update_peer_card silently truncates an over-cap card, so a card at the cap can never take a new entry

Author: dalzioCreated Sep 7, 2026Updated Sep 23, 2026
Labelsbughonchomaintainer-approved

Deploy mode

Self-hosted

Honcho version

server 3.1.1, self-hosted via Docker Compose

Describe the bug

When update_peer_card receives more entries than MAX_PEER_CARD_FACTS (40), it cuts everything past the cap and still reports the update as successful (src/utils/agent_tools.py, the if len(normalized_peer_card) > MAX_PEER_CARD_FACTS branch).

That has three consequences:

  1. The model is never told. The tool returns a success message, so the specialist has no way to learn that the marker it had just derived was dropped.
  2. What survives is decided by arrival order, not durability. [:MAX_PEER_CARD_FACTS] keeps the head of whatever list the model happened to send.
  3. A card at the cap can never take a new entry again. Each later run re-sends the surviving 40 entries plus its new marker, the surplus is cut, and the stored card stays byte-identical — indefinitely.

The same function already has the mechanism this case needs: structurally invalid entries are counted and reported back to the model through _format_rejection_feedback, which lets it self-correct on a retry. Only the length case is silent.

Steps to reproduce

  1. Let a peer card grow to 40 entries.
  2. Have a specialist with update_peer_card in its loadout derive one more durable identity marker, so it calls the tool with 41 entries.
  3. Observe: the log line Peer card update exceeded max facts (40), truncating from 41 to 40, a success result handed back to the model, and a stored card that is unchanged.

This also reproduces without a model: calling the tool handler directly with MAX_PEER_CARD_FACTS + 1 structurally valid entries returns a success result and stores the truncated list.

Logs and evidence

Observed on a self-hosted 3.1.1 deployment with a peer card sitting at the cap:

Peer card update exceeded max facts (40), truncating from 41 to 40

The stored card was byte-identical before and after the run, while the tool result reported a successful update.

Additional context

The current test suite pins the truncating behaviour: test_deduplicates_and_caps_peer_card in tests/utils/test_agent_tools.py asserts len(peer_card) == MAX_PEER_CARD_FACTS after sending an over-cap list, so a fix has to change that expectation deliberately.

I have a fix ready — refuse the over-cap list as a whole, leave the stored card untouched, and return a result that states how many entries to free and how — and will open a PR referencing this issue.