Preserve skill catalog entries under metadata pressure (#34732)

## Why

Long skill descriptions can consume the catalog's metadata budget before later
skills are listed, hiding otherwise usable skills from the model.

## What changed

- Reserve space for every skill's name and locator when those minimum lines fit.
- Distribute the remaining token or character budget across descriptions in
  round-robin order.
- Fall back to omitting entries only when the minimum catalog cannot fit.

## Testing

Added extension and production-turn coverage that verifies moderate budget
pressure keeps every catalog entry, shortens descriptions evenly, and avoids an
omission marker.

GitOrigin-RevId: 41971e4b47a86863b3839707b5cffcd8d83b888c
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-07-22 11:08:38 +00:00
1 parent 667b6bbaf1
commit 6278742c41
4 files changed
+384 -43

No files matched your search

+8 -6
View File
@@ -149,13 +149,15 @@ fn character_fallback_counts_multibyte_metadata_by_characters() {
}
#[test]
fn catalog_emits_omission_marker_when_every_skill_exceeds_budget() {
fn catalog_emits_omission_marker_when_every_minimum_skill_line_exceeds_budget() {
let oversized = entry(
"oversized",
&"x".repeat(MAX_CATALOG_SKILL_DESCRIPTION_CHARS),
/*short_description*/ None,
)
.with_display_path(format!("skill://{}", "x".repeat(512)));
let catalog = SkillCatalog {
entries: vec![entry(
"oversized",
&"x".repeat(MAX_CATALOG_SKILL_DESCRIPTION_CHARS),
/*short_description*/ None,
)],
entries: vec![oversized],
warnings: Vec::new(),
};