feat: Fairly trim skill descriptions within context budget (#18925)

Preserve skill name/path entries whenever possible and trim descriptions
first, using round-robin character allocation so short descriptions do
not waste budget.
This commit is contained in:
xl-openai authored and GitHub committed 2026-04-22 12:33:29 -07:00
1 parent ddde50c611
commit b77791c228
6 files changed
+587 -50

No files matched your search

@@ -191,7 +191,7 @@ async fn live_app_server_warning_notification_renders_message() {
chat.handle_server_notification(
ServerNotification::Warning(WarningNotification {
thread_id: None,
message: "Some enabled skills were not included in the model-visible skills list for this session. Mention a skill by name or path if you need it.".to_string(),
message: "Warning: Exceeded skills context budget of 2%. All skill descriptions were removed and 2 additional skills were not included in the model-visible skills list.".to_string(),
}),
/*replay_kind*/ None,
);
@@ -201,13 +201,13 @@ async fn live_app_server_warning_notification_renders_message() {
let rendered = lines_to_single_string(&cells[0]);
let normalized = rendered.split_whitespace().collect::<Vec<_>>().join(" ");
assert!(
normalized.contains(
"Some enabled skills were not included in the model-visible skills list for this session."
),
normalized.contains("Warning: Exceeded skills context budget of 2%."),
"expected warning notification message, got {rendered}"
);
assert!(
normalized.contains("Mention a skill by name or path if you need it."),
normalized.contains(
"All skill descriptions were removed and 2 additional skills were not included in the model-visible skills list."
),
"expected warning guidance, got {rendered}"
);
}