Skip to content

Conversation

@xl-openai
Copy link
Collaborator

@xl-openai xl-openai commented Dec 9, 2025

  1. Skills load once in core at session start; the cached outcome is reused across core and surfaced to TUI via SessionConfigured.
  2. TUI detects explicit skill selections, and core injects the matching SKILL.md content into the turn when a selected skill is present.

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

// Note that pending_input would be something like a message the user
// submitted through the UI while the model was running. Though the UI
// may support this, the model might not.
let pending_input = sess
.get_pending_input()

P1 Badge Pending user input bypasses SKILL injection

Skill contents are injected only once from the initial input (line 2139), but follow-up messages queued in pending_input inside the turn loop are never scanned for $<skill> mentions. If a user sends an additional message while the model is running that names a skill, that SKILL.md is never inlined, so the model responds without the requested instructions. Consider running inject_skills on pending_input before adding it to history so mid-turn skill mentions get the same treatment as the initial message.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

fn parse_user_message(message: &[ContentItem]) -> Option<UserMessageItem> {
if UserInstructions::is_user_instructions(message) {
if UserInstructions::is_user_instructions(message)
|| SkillInstructions::is_skill_instructions(message)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a test. see below in this file


pub const USER_INSTRUCTIONS_OPEN_TAG_LEGACY: &str = "<user_instructions>";
pub const USER_INSTRUCTIONS_PREFIX: &str = "# AGENTS.md instructions for ";
pub const SKILL_INSTRUCTIONS_PREFIX: &str = "# SKILL.md instructions for ";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just do the xml tag without the prefix.

}

impl From<SkillInstructions> for ResponseItem {
fn from(si: SkillInstructions) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a test. See examples below.

}
}

async fn inject_skills(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if re-parsing user message in core is the right approach.

It might be better to pass selected skills as one of UserInputs or as an explicit parameter on UserTurn similar to how we handle images.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other problem with the current approach is that new skills added during the session won't be mentionable. And the contents of the skills won't be reloaded.

/// Combines `Config::instructions` and `AGENTS.md` (if present) into a single
/// string of instructions.
pub(crate) async fn get_user_instructions(config: &Config) -> Option<String> {
pub(crate) async fn get_user_instructions(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now what we have a separate skills instruction element should we render skills into it instead of injecting skills into user instructions?

Copy link
Collaborator Author

@xl-openai xl-openai Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The skills list in project docs is for discovery/implicit triggers only. SKILL instructions are explicit “use this skill” signals that loop in the full SKILL.md context.

Copy link
Collaborator

@pakrym-oai pakrym-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR needs integration tests, that send user messages with skills and assert that correct information is sent to responses api.

@xl-openai xl-openai force-pushed the xl/skills branch 3 times, most recently from 630a6f1 to 55777bf Compare December 10, 2025 02:02
@xl-openai xl-openai requested a review from pakrym-oai December 10, 2025 02:24
@xl-openai
Copy link
Collaborator Author

@codex review again except for the issue with follow-up messages queued in pending_input

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

pub(crate) session_configuration: SessionConfiguration,
pub(crate) history: ContextManager,
pub(crate) latest_rate_limits: Option<RateLimitSnapshot>,
pub(crate) skills: Option<SkillLoadOutcome>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this onto SessionServices.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Session state contains frequently mutated state.

selected
}

fn paths_match(a: &Path, b: &Path) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this check?

}
}

async fn inject_skills(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please mode this and related skill helpers into skill.rs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also take session as a reference instead of having an instance method on it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to keep the size of codex.rs sane


fn skill_load_outcome_for_client(
outcome: Option<&SkillLoadOutcome>,
) -> Option<SkillLoadOutcomeInfo> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can move SkillLoadOutcome to the protocol directly and avoid double copies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the protocol type inside core would couple the loader/cache to the external serde/TS model. The current split keeps boundaries clean, and the mapping is trivial. wdyt?


pub const USER_INSTRUCTIONS_OPEN_TAG_LEGACY: &str = "<user_instructions>";
pub const USER_INSTRUCTIONS_PREFIX: &str = "# AGENTS.md instructions for ";
pub const SKILL_INSTRUCTIONS_PREFIX: &str = "<SKILL";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please do lower case, mostly to be consistent with other elements

role: "user".to_string(),
content: vec![ContentItem::InputText {
text: format!(
"<SKILL name=\"{name}\" path=\"{path}\">\n{contents}\n</SKILL>",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for env context we used sub tags instead of attributes. I don't have a strong opinion but might be good to stay consistent.

}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn user_turn_includes_skill_instructions() -> Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider a test for when skills fail to load.

}
}
},
UserInput::Skill { .. } => ContentItem::InputText {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct ? Should we be creating an extra empty content item?

Ok(())
}

pub async fn submit_items(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of our tests just call self.codex.submit(Op::UserTurn directly with whatever parameters they need.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise we'll end up with too many of these overloads.


let user_instructions = get_user_instructions(
&config,
skills_outcome.as_ref().and_then(|outcome| {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why aren't we passin outcome.skills directly?

@xl-openai
Copy link
Collaborator Author

@codex review again

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@xl-openai xl-openai merged commit b36ecb6 into main Dec 10, 2025
26 checks passed
@xl-openai xl-openai deleted the xl/skills branch December 10, 2025 21:59
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants