Structural fix for the Codex sub-agent recursion bug (Documentation Index
Fetch the complete documentation index at: https://docs.trytrellis.app/llms.txt
Use this file to discover all available pages before exploring further.
#240, #242). Removes the Codex SessionStart hook entirely and replaces the bootstrap path with a trellis-start skill invoked from UserPromptSubmit. No new migrations.
Bug Fixes
Codex sub-agent recursion (turtles all the way down)
Codex firesSessionStart for every spawned sub-agent session and exposes no agent_id / agent_type field on the hook input (openai/codex#16226). So the dispatch directive in packages/cli/src/templates/codex/hooks/session-start.py was being injected into every sub-agent’s session start payload as well — the sub-agent read “Next required action: dispatch trellis-implement”, thought it was the main session, and spawned its own trellis-implement. Then that sub-agent did the same thing.
The 0.5.4 patch (#237) added a Sub-agent self-exemption: clause to the same prompt block, but it sat inline alongside the dispatch directive. LLMs kept picking the command-style instruction over the conditional exemption.
Structural fix:
- Removed the
SessionStartentry frompackages/cli/src/templates/codex/hooks.json— the heavy session-start payload no longer reaches any session, sub-agent or main. packages/cli/src/templates/shared-hooks/inject-workflow-state.py(UserPromptSubmit) now injects a<trellis-bootstrap>block onno_taskturns that tells the AI to invoke$trellis-startonce. The notice carries an explicit sub-agent exemption (sub-agents read the existing<sub-agent-notice>first and skip everything below it).packages/cli/src/configurators/codex.tswrites.agents/skills/trellis-start/SKILL.mdfor Codex. The skill content is the existingcommon/commands/start.mdtemplate wrapped with skill frontmatter.
<sub-agent-notice> from the per-turn breadcrumb. No command-style “must dispatch” text exists anywhere in the new injection, so the recursion vector is gone at source.
Other agent-capable platforms (Claude Code, Cursor, OpenCode, Kiro, etc.) keep their working SessionStart hooks unchanged — only Codex is affected by openai/codex#16226.
Upgrade
.agents/skills/trellis-start/SKILL.md file and a hooks.json without SessionStart wiring. No flag needed.