Fix extension skills guidance routing

This commit is contained in:
ani-oai
2026-06-18 14:16:20 -07:00
parent 8e315ac027
commit b693c6f22c
8 changed files with 36 additions and 7 deletions
@@ -138,7 +138,7 @@ async fn orchestrator_skill_can_read_referenced_resource_without_an_executor() -
let thread_start_id = mcp
.send_thread_start_request(ThreadStartParams {
model: Some("mock-model".to_string()),
model: Some("gpt-5.5".to_string()),
environments: Some(Vec::new()),
..Default::default()
})
+1
View File
@@ -20,6 +20,7 @@ pub use model::SkillMetadata;
pub use model::SkillPolicy;
pub use model::filter_skill_load_outcome_for_product;
pub use render::AvailableSkills;
pub use render::LegacySkillsInstructions;
pub use render::SKILLS_HOW_TO_USE_WITH_ABSOLUTE_PATHS;
pub use render::SKILLS_HOW_TO_USE_WITH_ALIASES;
pub use render::SKILLS_INTRO_WITH_ABSOLUTE_PATHS;
+4 -1
View File
@@ -59,8 +59,11 @@ pub const SKILLS_HOW_TO_USE_WITH_ALIASES: &str = r###"- Discovery: The list abov
- When variants exist (frameworks, providers, domains), pick only the relevant reference file(s) and note that choice.
- Safety and fallback: If a skill can't be applied cleanly (missing files, unclear instructions), state the issue, pick the next-best approach, and continue."###;
#[derive(Clone, Copy, Debug)]
pub struct LegacySkillsInstructions;
pub fn render_available_skills_body(skill_root_lines: &[String], skill_lines: &[String]) -> String {
render_skills_body(skill_root_lines, skill_lines, None)
render_skills_body(skill_root_lines, skill_lines, /*how_to_use*/ None)
}
pub fn render_legacy_available_skills_body(
@@ -1,6 +1,6 @@
use codex_core_skills::AvailableSkills;
use codex_core_skills::render_available_skills_body;
use codex_core_skills::render::render_legacy_available_skills_body;
use codex_core_skills::render_available_skills_body;
use codex_protocol::protocol::SKILLS_INSTRUCTIONS_CLOSE_TAG;
use codex_protocol::protocol::SKILLS_INSTRUCTIONS_OPEN_TAG;
+10
View File
@@ -3,6 +3,7 @@ use crate::agents_md::LoadedAgentsMd;
use crate::environment_selection::TurnEnvironmentSnapshot;
use crate::shell_snapshot::ShellSnapshotFile;
use codex_core_skills::HostSkillsSnapshot;
use codex_core_skills::LegacySkillsInstructions;
use codex_file_system::FileSystemSandboxContext;
use codex_model_provider::SharedModelProvider;
use codex_model_provider::create_model_provider;
@@ -712,6 +713,15 @@ impl Session {
&per_turn_config.to_models_manager_config(),
)
.await;
if model_requires_legacy_skills_instructions(&model_info.slug) {
self.services
.thread_extension_data
.insert(LegacySkillsInstructions);
} else {
self.services
.thread_extension_data
.remove::<LegacySkillsInstructions>();
}
let multi_agent_version = match multi_agent_runtime {
TurnMultiAgentRuntime::ResolveAndStore => {
+5 -2
View File
@@ -1,6 +1,7 @@
use std::sync::Arc;
use codex_core_skills::HostSkillsSnapshot;
use codex_core_skills::LegacySkillsInstructions;
use codex_core_skills::injection::InjectedHostSkillPrompts;
use codex_exec_server::LOCAL_ENVIRONMENT_ID;
use codex_extension_api::ConfigContributor;
@@ -133,7 +134,8 @@ where
for warning in &catalog.warnings {
self.emit_warning(thread_store.level_id(), warning.clone());
}
available_skills_fragment(&catalog)
let legacy = thread_store.get::<LegacySkillsInstructions>().is_some();
available_skills_fragment(&catalog, legacy)
.map(|fragment| PromptFragment::developer_capability(fragment.render()))
.into_iter()
.collect()
@@ -207,7 +209,8 @@ where
entry.authority.kind != SkillSourceKind::Executor
&& entry.authority.kind != SkillSourceKind::Orchestrator
});
if let Some(fragment) = available_skills_fragment(&turn_catalog) {
let legacy = thread_store.get::<LegacySkillsInstructions>().is_some();
if let Some(fragment) = available_skills_fragment(&turn_catalog, legacy) {
fragments.push(Box::new(fragment));
}
}
+9 -1
View File
@@ -1,3 +1,4 @@
use codex_core_skills::SKILLS_HOW_TO_USE_WITH_ABSOLUTE_PATHS;
use codex_core_skills::render_available_skills_body;
use codex_extension_api::ContextualUserFragment;
use codex_protocol::protocol::SKILLS_INSTRUCTIONS_CLOSE_TAG;
@@ -9,7 +10,14 @@ pub(crate) struct AvailableSkillsInstructions {
}
impl AvailableSkillsInstructions {
pub(crate) fn from_skill_lines(skill_lines: Vec<String>) -> Self {
pub(crate) fn from_skill_lines(
mut skill_lines: Vec<String>,
include_legacy_usage_instructions: bool,
) -> Self {
if include_legacy_usage_instructions {
skill_lines.push("### How to use skills".to_string());
skill_lines.push(SKILLS_HOW_TO_USE_WITH_ABSOLUTE_PATHS.to_string());
}
Self { skill_lines }
}
}
+5 -1
View File
@@ -12,6 +12,7 @@ pub(crate) const MAX_SKILL_PATH_BYTES: usize = 1_024;
pub(crate) fn available_skills_fragment(
catalog: &SkillCatalog,
include_legacy_usage_instructions: bool,
) -> Option<AvailableSkillsInstructions> {
let mut total_bytes = 0usize;
let mut omitted = 0usize;
@@ -46,7 +47,10 @@ pub(crate) fn available_skills_fragment(
));
}
Some(AvailableSkillsInstructions::from_skill_lines(skill_lines))
Some(AvailableSkillsInstructions::from_skill_lines(
skill_lines,
include_legacy_usage_instructions,
))
}
fn render_skill_line(entry: &SkillCatalogEntry, description: &str) -> String {