Add a configurable skill catalog token budget (#38978)

## What changed

- Add `[skills].max_context_tokens` to override the token budget used to render the available-skills catalog.
- Require a positive value and cap configured budgets at 10,000 tokens.
- Preserve the existing default of 2% of the model context window when the option is unset.

## Testing

- Cover configuration parsing, override behavior, the 10,000-token cap, and catalog rendering within the configured budget.

GitOrigin-RevId: f29ddcb57fc2d800c0006d03e1c33cbe3ab6272d
This commit is contained in:
jif
2026-08-17 10:01:59 +00:00
committed by copyberry
parent c6058ccaa9
commit 632e35ce8d
19 changed files with 126 additions and 7 deletions
+6
View File
@@ -1,6 +1,7 @@
//! Skill-related configuration types shared across crates.
use std::collections::HashSet;
use std::num::NonZeroUsize;
use crate::ConfigLayerSource;
use crate::ConfigLayerStack;
@@ -36,6 +37,11 @@ pub struct SkillsConfig {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub include_instructions: Option<bool>,
/// Maximum tokens used by the available-skills catalog. Defaults to 2% of
/// the model context window and is capped at 10,000 tokens when set.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_context_tokens: Option<NonZeroUsize>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub config: Vec<SkillConfig>,
}