Stop dropping Context collections from the agent catalog - #208
Stop dropping Context collections from the agent catalog#208AshishKumar4 wants to merge 1 commit into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
The agent saw a truncated Context Library: with hundreds of skills, collections went missing from its discovery catalog. Two causes. `AGENT_CATALOG_MAX_ENTRIES` was 25, which a library with a handful of public collections already exceeds. And `normalizeAgentCatalog` sorted the combined list by title *before* clamping it, so which entries survived was decided by alphabetical position — collections competed with skills on title, and a collection titled "Zulu" lost to every `aa-*` skill name. Raising the cap alone would only move that threshold. So the clamp now drops from the tail and sorts the survivors, making the gatekeeper's ordering the priority signal, and the Context gatekeeper lists its collections ahead of its skills. Collections are the agent's entry points; individual skills past the cap stay reachable through the session's list()/search(). The cap goes to 200 rather than higher because the catalog is inlined in the system prompt on every turn and compaction never reaches it, so the entry count is a direct, permanent context cost (~80 KB at 200 entries). `boundAgentCatalog()` and `AgentCatalogRequest` go away with it. The request limit was always AGENT_CATALOG_MAX_ENTRIES, a constant both sides already import, so it carried no information, and the provider-side clamp only duplicated the Workshop's. One bound, in the kernel, on untrusted input.
7180f71 to
2835253
Compare
|
Confirmed: skills are internally sorted, collections are internally sorted, and they're concatenated collections-first. Since the Workshop drops from the tail, collections survive unless collection count alone exceeds 200 — the intended guarantee. I've completed a thorough review of this PR. Here's my assessment: SummaryThe change is coherent, correct, and well-contained. It fixes the "collections dropped from the agent catalog" bug via two mechanisms:
Verification
The one non-blocking design tradeoff (if skills alone reach 200, collections could still be dropped) is genuinely mitigated by collections-first ordering: collections survive unless the collection count itself exceeds 200, a much stronger guarantee than before. No new actionable code defects found. LGTM! |
With hundreds of skills, the agent gets a truncated view of its Context Library and collections go missing. Missing a collection is a much bigger problem than missing a skill: collections are how the agent finds anything at all, and individual skills can be enumerated on demand through the session's
list()/search().There were two causes.
AGENT_CATALOG_MAX_ENTRIESwas 25, which a deployment with a handful of public collections already exceeds on its own.The bigger one:
normalizeAgentCatalogsorted the combined list by title before clamping it, so which entries survived was decided purely by alphabetical position. Collections competed against skills on title. Raising the cap alone would only have moved the threshold at which that reappears, so this fixes the drop policy instead.What does this change?
normalizeAgentCatalogclamps from the tail and sorts the survivors, so the gatekeeper's ordering is the priority signal rather than the alphabetAGENT_CATALOG_MAX_ENTRIES25 → 200boundAgentCatalog()andAgentCatalogRequestare removed200 rather than something larger because the catalog is inlined in the system prompt on every turn and compaction never reaches it, so the entry count is a direct and permanent context cost — roughly 80 KB at 200 entries and the field caps.
On the removal:
request.limitwas alwaysAGENT_CATALOG_MAX_ENTRIES, a constant both sides already import from this module, so the parameter carried no information, and the provider-side clamp only duplicated the one the Workshop applies anyway. That leaves a single bound, in the kernel, on untrusted input. This changes thegetAgentCatalogsignature, which both gatekeepers validate throughcapnweb-validate, so it assumes the Workshop and an installed gatekeeper are never left at mismatched versions.Why is this obviously correct and trivially verifiable?
The behavioural change is one moved
.toSorted()and one reordered array concatenation. The new test inagent-catalog.test.tsfails on the old sort-then-slice ordering and passes on the new one; theidlength bound that the deletedboundAgentCatalogsuite used to assert is now covered againstnormalizeAgentCatalog, which is the only bound left.Checklist
Checking every item does not guarantee acceptance. Maintainers determine whether
a pull request meets the contribution policy.