Skip to content

Stop dropping Context collections from the agent catalog - #208

Merged
AshishKumar4 merged 1 commit into
mainfrom
fix/collections-truncated
Aug 18, 2026
Merged

Stop dropping Context collections from the agent catalog#208
AshishKumar4 merged 1 commit into
mainfrom
fix/collections-truncated

Conversation

@AshishKumar4

@AshishKumar4 AshishKumar4 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What does this change?

With hundreds of skills the agent saw a truncated Context Library, and collections went missing from it. Collections are how the agent finds anything at all; individual skills it can enumerate through the session's list()/search().

The returned catalog was always being bounded to a low value of 25, and at both, before returning the values in RPC and an outer bound, which made most of the skills and collections be truncated.
This PR fixes that by increasing the outer bound threshold, and separately bounding the skills catalog to a value of 150.
This PR also simplifies the getAgentCatalog API by removing the request field.
Also, normalizeAgentCatalog clamps from the tail and sorts the survivors, so the gatekeeper's order decides what lives

Why is this obviously correct and trivially verifiable?

The behavioural change is one moved .toSorted() and one reordered concatenation. The catalog policy moved into buildContextCatalog(), so it reads as a single pure function instead of being spread through a Durable Object method.

Checklist

Checking every item does not guarantee acceptance. Maintainers determine whether
a pull request meets the contribution policy.

  • This is a small, concrete change; it is not a feature, refactor, or low-value cleanup.
  • I understand that maintainers decide whether the change is obviously correct and trivially verifiable.
  • I have read and followed the contribution guidelines.

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot added the gatekeeper Changes to a gatekeeper integration label Aug 14, 2026
@AshishKumar4

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 14, 2026
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
@github-actions github-actions Bot added the workshop/shared Changes to shared Workshop APIs label Aug 14, 2026
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
@AshishKumar4 AshishKumar4 changed the title Fix: agents seeing highly truncated list of collections and skills Draft: Fix: agents seeing highly truncated list of collections and skills Aug 14, 2026
@AshishKumar4
AshishKumar4 marked this pull request as draft August 14, 2026 15:58
@github-actions github-actions Bot added the kernel Changes to the Workshop kernel label Aug 14, 2026
@cloudflare cloudflare deleted a comment from ask-bonk Bot Aug 14, 2026
@cloudflare cloudflare deleted a comment from ask-bonk Bot Aug 14, 2026
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
Comment thread packages/workshop-backend/src/agent-catalog.ts Outdated
Comment thread packages/workshop-backend/src/agent-catalog.ts Outdated
Comment thread packages/workshop-shared/src/gatekeeper.ts
@AshishKumar4 AshishKumar4 changed the title Draft: Fix: agents seeing highly truncated list of collections and skills Stop dropping Context collections from the agent catalog Aug 14, 2026
@cloudflare cloudflare deleted a comment from ask-bonk Bot Aug 14, 2026
@AshishKumar4
AshishKumar4 force-pushed the fix/collections-truncated branch from 7180f71 to 2835253 Compare August 14, 2026 21:45
@ask-bonk

ask-bonk Bot commented Aug 14, 2026

Copy link
Copy Markdown

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:

Summary

The change is coherent, correct, and well-contained. It fixes the "collections dropped from the agent catalog" bug via two mechanisms:

  1. normalizeAgentCatalog switches from sort-then-slice to slice-then-sort (agent-catalog.ts:43-45). This makes the gatekeeper's provider ordering the priority signal, so tail-drop discards the last-listed entries rather than the alphabetically-last ones.
  2. The Context gatekeeper lists collections before skills (library-gatekeeper.ts:338), so a large skill set can no longer push collections past the cap.

Verification

  • No dangling references: boundAgentCatalog/AgentCatalogRequest are fully removed with no remaining importers (checked repo-wide).
  • Signature change is consistent across all three sides: both gatekeepers (scheduler.ts:272, library-gatekeeper.ts:319) drop the request param, and the overseer call site (overseer.ts:4866) drops the argument. The derived CatalogGatekeeperFacet type flows correctly with no wire-format change.
  • Logging follows conventions: module-scoped createWorkshopLogger, concrete dot-separated event: "agent.catalog.truncated", and size is a real member of WorkshopObservabilityFields (observability.ts:27).
  • All prior review findings resolved: no unused VENDOR_ID/obsContext imports, doc comments updated (gatekeeper.ts:716-723), security/defense rationale retained and clarified (agent-catalog.ts:19-27).
  • The new test genuinely distinguishes old vs new behavior (agent-catalog.test.ts:41-56): the "keep" entry with a last-sorting title survives the cap only under slice-then-sort. The deleted boundAgentCatalog suite's id-length assertion is now covered by the extended normalizeAgentCatalog test (agent-catalog.test.ts:24).
  • PR body matches the code as provided to me (25→200, symbols removed) — the stale-metadata note in earlier bot comments referred to an intermediate commit.

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!

github run

@cloudflare cloudflare deleted a comment from ask-bonk Bot Aug 14, 2026
@cloudflare cloudflare deleted a comment from ask-bonk Bot Aug 14, 2026
@AshishKumar4
AshishKumar4 marked this pull request as ready for review August 14, 2026 21:48
@AshishKumar4
AshishKumar4 force-pushed the fix/collections-truncated branch from 2835253 to 622afd0 Compare August 17, 2026 15:41
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts
Comment thread packages/workshop-shared/src/gatekeeper.ts Outdated
Comment thread packages/gatekeeper-context/src/library-gatekeeper.ts Outdated
@AshishKumar4
AshishKumar4 force-pushed the fix/collections-truncated branch from 622afd0 to e11d864 Compare August 17, 2026 22:57
@ask-bonk

ask-bonk Bot commented Aug 17, 2026

Copy link
Copy Markdown

github run

@ask-bonk

ask-bonk Bot commented Aug 17, 2026

Copy link
Copy Markdown

@AshishKumar4 Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

@github-actions github-actions Bot added the delivery Changes to CI or release delivery label Aug 18, 2026
@ask-bonk

ask-bonk Bot commented Aug 18, 2026

Copy link
Copy Markdown

github run

@AshishKumar4
AshishKumar4 force-pushed the fix/collections-truncated branch from e1bf086 to 79f74fb Compare August 18, 2026 14:53
@github-actions github-actions Bot removed the delivery Changes to CI or release delivery label Aug 18, 2026
@ask-bonk

ask-bonk Bot commented Aug 18, 2026

Copy link
Copy Markdown

github run

@AshishKumar4
AshishKumar4 force-pushed the fix/collections-truncated branch from 79f74fb to ad7e612 Compare August 18, 2026 15:01
@ask-bonk

ask-bonk Bot commented Aug 18, 2026

Copy link
Copy Markdown

github run

Comment thread packages/workshop-shared/src/gatekeeper.ts
@AshishKumar4

Copy link
Copy Markdown
Contributor Author

bonk break glass

@github-actions github-actions Bot added the bonk-break-glass Skip automatic Bonk PR review label Aug 18, 2026
Cap advertised skills at 150 and put collections first. The shared 1000-entry
limit remains a final backstop, applied both before RPC and again by the
Workshop. The Workshop now clamps before sorting so the gatekeeper's priority
order determines which entries survive.

Remove the redundant catalog request parameter; its limit was always the shared
constant already imported by both sides.
@AshishKumar4
AshishKumar4 force-pushed the fix/collections-truncated branch from ad7e612 to 7971609 Compare August 18, 2026 15:30
@AshishKumar4
AshishKumar4 merged commit 2c9d590 into main Aug 18, 2026
13 checks passed
@AshishKumar4
AshishKumar4 deleted the fix/collections-truncated branch August 18, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bonk-break-glass Skip automatic Bonk PR review gatekeeper Changes to a gatekeeper integration kernel Changes to the Workshop kernel workshop/shared Changes to shared Workshop APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants