Repository navigation
fix(workspace): make the / typeahead able to find every skill the agent offers (#2213) - #2254
Conversation
…gent offers (#2213) DIAGNOSIS FIRST — measured, on a live instance, with 30 probe skills planted in a real agent container so the tiers could be compared against one agent: agent-server GET /api/skills 33 skills, all user_invocable roster payload playbooks[] 24 <- _MAX_BRIEFING_HINTS popup, query "probe 27" 0 matches, and nothing on screen saying why So of the four candidate narrowing steps: the container scan found everything (tier 3), the exposure filter dropped nothing (tier 2 — no allow-list, all invocable), and the popup's own limit of 8 was already honest, rendering "N more — keep typing to filter" (tier 4). The defect is tier 1: the payload bound. 24 is right for the hint-card GRID it was written for (#2101 — a card surface has a layout limit and cards carry descriptions) and wrong as the SEARCH corpus, because search cannot reach what never shipped, and the popup has no way to know it is holding a truncated list. So the two surfaces get two bounds and the true count is published: * `playbooks` — unchanged: 24, rich, for the cards * `searchable_playbooks` — the same client-visible set at 200, title + starter only (dropping descriptions is what makes 200 entries cheap: ~40 chars each rather than ~540), feeding `/` * `playbooks_total` — the count before either bound The popup now distinguishes the two omissions instead of blurring them: `overflow` is rows it chose not to draw and typing will reach; `hiddenCount` is skills that never reached the browser, which typing cannot reach — so it says "N more not listed here — ask for it by name", and the screen-reader status says the same. A bounded list is fine; a bounded list that looks complete is the bug. Widening the briefing's return broke five test files, including two that FAKE `_agent_briefing` with a 2-tuple — the #2242 stale-double class, arriving as a 500 in the roster build rather than a failed assertion. So the return is a named `AgentBriefing` NamedTuple (still a tuple, so the `isinstance` guards hold) and one `_apply_briefing` helper copies it onto the card positionally-tolerantly, absorbing any stub that still returns the old shape. That took the fallout from 26 failures to 5, and those 5 were tests asserting the old shape directly — updated to read fields by name, so a future field cannot silently shift what they assert. My own test caught a real defect mid-change: the availability early-return still yielded a 2-tuple, which would have raised ValueError on unpack for every stopped or unavailable agent — breaking the roster on exactly the agents that return exists to serve cheaply. PLUGIN SKILLS (tier 3) are declared OUT OF SCOPE and documented at the scan, per the AC's second option. Enumerating them means reading the plugin cache layout in `agent_server/routers/skills.py`, which ships in the base image — so an instance only gets it after a rebuild, and old images silently keep the old surface, the release-note trap ent#123 already paid for once. The Workspace consequence is now bounded and honest rather than invisible. Verified: 180 backend tests across every briefing/roster/connector suite, 851 frontend unit tests (10 new, over a set larger than BOTH bounds — the case the AC names and the case the old tests never exercised), design-token check and prod build clean. NOT verified live post-fix: the running instance bind-mounts a different worktree, and I am not editing a colleague's checkout or repointing their stack to prove my own branch — that check belongs to the deploy. Related to #2213 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ed defaults (#2213) Seven review findings, five of them real defects introduced by round one. * FIELD CAPS BYPASSED. `searchable_playbooks` was built from `playbooks` BEFORE `_bound_briefing_hints` applied its title/starter caps, so up to 200 uncapped strings shipped per card per roster load — and skill `name` comes from agent-author-controlled YAML frontmatter, which also feeds what a pick inserts into the composer. The copies now clamp with the same constants. * EVERY `/` ROW LOST ITS SUBTITLE. Searchable entries deliberately carry no description (that is what makes 200 entries cheap), and the popup renders `secondary: c.description || ''` — so pointing search at them blanked the subtitle for ALL agents, including those under the card bound whose descriptions did ship. `playbookSearchSource` now merges descriptions back by title: restored wherever one exists, blank only for the tail that genuinely has none, and the payload is not mutated. * `playbooks_total` UNDER-REPORTED on the use-case fallback tier, because `_use_case_hints` truncates to 6 before the count was taken — so an agent declaring 10 use-cases reported 0 hidden while 4 were dropped. The same "looks complete" bug this issue exists to fix, one tier over. Counted before the cap now. * SHARED MUTABLE DEFAULTS. `AgentBriefing`'s `playbooks: list = []` is a CLASS-level default, so every stopped/failed agent's card aliased one list — in a module whose `_bound_briefing_hints` mutates hint objects in place. Defaults are immutable `()` now, which pydantic coerces on the card. * THE HIDDEN COUNT RENDERED MID-QUERY, where "N more not listed here" reads as "N more results matching what you typed" — false, since typing can never reach them. It now shows only on a bare `/`, where it is a property of the list. * The #2101 comment block documenting `_MAX_BRIEFING_HINTS` had been orphaned 14 lines from its constant by the new class; moved back. * My own test tautology: `_briefing(n) if n else (...)` short-circuited the `n == 0` case, so the empty-skills path — where the fallback tier takes over — was never exercised. Two shape assertions moved from `== (None, [], [], 0)` to per-field checks, because what the contract owes a caller is "nothing", not a particular container type. New regression tests: field caps hold for both surfaces under 4000-char names, the use-case tier's hidden count is visible, the defaults are immutable, and the subtitle merge is correct (restored / blank tail / no mutation / no-op when nothing has one). Verified: 11 tests in this file plus the ent#79 / #2196 / ent#357 briefing suites. Related to #2213 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review round applied (7 findings)Pushed
Plus the orphaned #2101 comment moved back to its constant, and my own test tautology: New regression tests: caps hold under 4000-char names, the use-case tier's hidden count is visible, defaults are immutable, and the subtitle merge is correct in all four directions. 127 tests across this file plus the ent#79 / #2196 / ent#357 briefing suites. |
…ll-coverage # Conflicts: # src/frontend/src/components/portal/PortalConversation.vue # src/frontend/src/components/portal/portalUtils.js # tests/registry.json
…ll-coverage # Conflicts: # tests/registry.json
…ll-coverage # Conflicts: # tests/registry.json
vybe
left a comment
There was a problem hiding this comment.
Validated via /validate-pr.
The defect is correctly located at the payload bound, not the popup: _MAX_BRIEFING_HINTS (24) is right for the hint-card GRID it was written for (#2101 — a card surface has a layout limit and cards carry descriptions) and wrong as the search corpus, because search cannot reach what never shipped. Splitting into playbooks (cards) / searchable_playbooks (200, title+starter only, which is what keeps it cheap) / playbooks_total (so remaining truncation is sayable rather than silent) is the right shape, and the exposure policy still bounds both surfaces.
Two details worth calling out as good:
-
AgentBriefinguses immutable tuple defaults — a NamedTuple's defaults are class-level, so[]would be one shared list aliased by every stopped agent's card, in a module that mutates hint lists in place. -
_apply_briefingis positional-tolerant on purpose, absorbing test doubles still returning the pre-#2213 2-tuple. That is the #2242 class, and without it a stale double becomes a 500 in the roster build rather than a failed assertion — it took the fallout from 26 failures to 5. -
Security scan: clean
-
uilabel present, sobuildande2eboth ran -
Merged
origin/devand resolved three conflicts by hand:portalUtils.jsandPortalConversation.vueagainst #2256 (both append-only; kept both functions and both imports) andtests/registry.jsonagainst #2251/#2252/#2255 (rebuilt from git stages, never spliced — verified no entry modified or deleted on either side). Post-resolve: full frontend suite 875/875, portal backend tests 128/128. -
Verified the resolved branch diffs against dev in exactly its own 11 files — no leakage from the PRs it merged over.
-
Closing keyword patched in so #2213 auto-promotes
Diagnosis first (AC#1), measured on a live instance
I planted 30 probe skills in a real agent container so all four tiers could be compared against one agent:
GET /api/skills(in container)user_invocableplaybooks[]_MAX_BRIEFING_HINTS"probe 27"So of the four candidates: the container scan found everything (tier 3), the exposure filter dropped nothing (tier 2 — no allow-list, everything invocable), and the popup's own limit of 8 was already honest, rendering "N more — keep typing to filter" (tier 4).
Tier 1, the payload bound, is the defect. 24 is right for the hint-card grid it was written for (#2101 — a card surface has a layout limit, and cards carry descriptions) and wrong as the search corpus, because search cannot reach what never shipped and the popup has no way to know its list is truncated.
The fix: two surfaces, two bounds, one honest count
playbooks— unchanged. 24, rich, feeds the cards.searchable_playbooks— the same client-visible set at 200, title + starter only. Dropping descriptions is what makes 200 entries cheap: ~40 chars each instead of ~540.playbooks_total— the count before either bound.The popup now keeps the two omissions distinct instead of blurring them:
overflow— rows it chose not to draw; typing reaches themhiddenCount— skills that never reached the browser; typing cannot — so it says "N more not listed here — ask for it by name", and the screen-reader status says the sameA bounded list is fine. A bounded list that looks complete is the bug.
Two things worth a reviewer's attention
Widening the briefing's return broke five test files, two of which FAKE
_agent_briefingwith a 2-tuple — the #2242 stale-double class, and it would have surfaced as a 500 in the roster build rather than a failed assertion. So the return is a namedAgentBriefingNamedTuple (still a tuple, so the existingisinstanceguards hold) and one_apply_briefinghelper copies it onto the card positionally-tolerantly, absorbing any stub still returning the old shape. That took the fallout from 26 failures to 5, and those 5 were asserting the old shape directly — updated to read fields by name, so a future field cannot silently shift what they assert.My own test caught a real defect mid-change. The availability early-return still yielded a 2-tuple, which would have raised
ValueErroron unpack for every stopped or unavailable agent — breaking the roster on exactly the agents that early return exists to serve cheaply.Plugin skills (tier 3): out of scope, documented
Taking the AC's second option, with the reasoning recorded at
scan_skills_directory. Enumerating plugin-provided skills means reading the plugin cache layout inagent_server/routers/skills.py, which ships in the base image — so an instance only gets it after a rebuild and old images silently keep the old surface, the release-note trap ent#123 already paid for once. The Workspace consequence is now bounded and honest rather than invisible, which is what makes deferring it defensible.Verification
Not verified live post-fix, deliberately: the running instance bind-mounts a different worktree (#2157's), and I am not editing a colleague's checkout or repointing their stack to prove my own branch. The pre-fix measurement above is real; the post-fix confirmation belongs to the deploy.
Fixes #2213
🤖 Generated with Claude Code