pub struct SkillReinjector {
pub token_budget: usize,
pub per_skill_budget: usize,
pub skills: Vec<Skill>,
}Expand description
Post-compaction re-injector for invoked skills.
When a Skill (LoadSkill) tool was called mid-session, its body lived
in the transcript as part of the tool result. After an LLM-summary
compaction the body is gone (folded into the summary’s prose), so the
model loses the skill’s operating instructions and may stop following
them. This reinjector recovers the invoked set by scanning the
pre-compaction transcript for Skill/LoadSkill/load_skill tool
calls, looks up bodies from the discovered Vec<Skill>, and emits
[Role::System] attachment messages.
Only emits [Role::System] messages — no [Role::Tool] messages, so
no orphan tool result can be created (invariant #8 safe).
Fields§
§token_budget: usizeTotal token budget across all re-injected skills (default 25_000). Tokens are estimated as chars / 4.
per_skill_budget: usizePer-skill content budget in tokens (default 5_000).
skills: Vec<Skill>Discovered skill catalog to look up bodies.
Implementations§
Source§impl SkillReinjector
impl SkillReinjector
Sourcepub fn new(skills: Vec<Skill>) -> Self
pub fn new(skills: Vec<Skill>) -> Self
Create a new SkillReinjector with the given skill catalog and
default limits (token_budget=25_000, per_skill_budget=5_000).
Sourcepub fn reinject(&self, pre_compact: &[Message]) -> Vec<Message>
pub fn reinject(&self, pre_compact: &[Message]) -> Vec<Message>
Scan pre_compact for Skill/LoadSkill/load_skill tool calls,
collect distinct skill names in invocation order, look up each in
self.skills, and emit [Role::System] attachment messages
(head-truncated to budget).
Returns an empty Vec when no invoked skills are found or the
catalog is empty.