Skip to content

fix(agent): inject local skill context into codex follow-up prompts#3399

Merged
tatoalo merged 1 commit into
mainfrom
posthog-code/codex-follow-up-skill-context
Jul 13, 2026
Merged

fix(agent): inject local skill context into codex follow-up prompts#3399
tatoalo merged 1 commit into
mainfrom
posthog-code/codex-follow-up-skill-context

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Problem

Codex cloud runs don't reliably recognize local skills after the first message. The sandbox agent installs uploaded skill bundles to disk and passes the invoked skill's definition via _meta.localSkillContext, but only the Claude adapter consumed that meta. codex adapter dropped it. Since codex bakes its skill catalog into the thread at start, a skill first invoked in a follow-up message was installed to disk but never became visible to the model: the /my-skill text reached codex as meaningless plain text.

Two adjacent gaps had the same effect even for Claude:

  • auto-bundled dependency skills (feat(skills): auto-bundle declared skill dependencies in cloud runs #3057) are installed silently, so nothing told the model they exist or where they live when they arrived mid-session;
  • a mid-message mention ("use /my-skill for this", or a skill chip anywhere in the text) installs the bundle but produced no skill context at all — the context builder only fired for message-leading /name invocations.

Changes

  • update the Codex adapter to consume localSkillContext and localSkillName, prepending inlined skill definitions to the prompt and stripping the /skill invocation only when appropriate. Prompt ordering is prContextlocalSkillContext → remaining user input

  • include all installed skills and their paths in the agent-server prompt, allowing the model to resolve references between bundled or previously installed skills

  • add a fallback for messages that install skill bundles without directly invoking one, inlining referenced skill definitions and listing the remaining installed skills with their paths

@trunk-io

trunk-io Bot commented Jul 13, 2026

Copy link
Copy Markdown

😎 Merged manually by @tatoalo - details.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 166536e.

@tatoalo tatoalo self-assigned this Jul 13, 2026
@tatoalo tatoalo marked this pull request as ready for review July 13, 2026 16:38
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 13, 2026
@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(agent): announce mid-message skill i..." | Re-trigger Greptile

Comment thread packages/agent/src/server/agent-server.ts Outdated
github-actions[bot]
github-actions Bot previously approved these changes Jul 13, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well-tested fix that extends skill context injection to Codex follow-up prompts, mirroring the existing Claude adapter. No showstoppers: the interface change is backward-compatible, the new fallback path is guarded, and the prompt-building logic is coherent.

Codex bakes its skill catalog into the thread when it starts, so a
local skill bundle installed by a follow-up message is invisible to it.
The Claude adapter already consumes _meta.localSkillContext to inline
the invoked skill's definition; the codex adapter dropped it, so
follow-up /my-skill invocations reached codex as meaningless plain text.

- codex adapter: consume localSkillContext/localSkillName — prepend the
  inlined skill definition to the forwarded turn input and drop the
  bare /name chunk (echo unchanged), mirroring the Claude adapter.
- agent-server: list co-installed skills (auto-bundled dependencies and
  skills from earlier messages) with their installed paths in the
  injected context.
- agent-server: announce mid-message skill installs — messages that
  install bundles without being a bare invocation get a context that
  inlines skills named in the message (token-boundary matched) and
  lists the rest by path.
@tatoalo tatoalo force-pushed the posthog-code/codex-follow-up-skill-context branch from 549adcc to 166536e Compare July 13, 2026 16:51
@github-actions github-actions Bot dismissed their stale review July 13, 2026 16:51

New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well-scoped fix that extends local skill context injection to the Codex adapter, mirroring the existing Claude adapter. The Greptile P1 concern about prefix-matching was addressed with a token-boundary regex and confirmed resolved. Interface change is backward-compatible, the fallback path is correctly guarded, and new behavior is covered by tests.

@tatoalo tatoalo enabled auto-merge (squash) July 13, 2026 17:04
@gantoine gantoine disabled auto-merge July 13, 2026 17:08
@gantoine

Copy link
Copy Markdown
Member

/trunk merge

@tatoalo tatoalo merged commit 20cad4d into main Jul 13, 2026
26 checks passed
@tatoalo tatoalo deleted the posthog-code/codex-follow-up-skill-context branch July 13, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants