Add automatic workflow injection layer
Resolved 💬 1 comment Opened May 9, 2026 by MoonlightByte Closed May 9, 2026
Automatic Workflow Injection Layer
Summary
Implement a native Rust workflow-injection layer that automatically selects compact task guidance from the user’s request and injects it into model calls. This replaces the bad learned behavior of reading Superpowers SKILL.md files while preserving the useful workflow structure.
The injection must apply to both main model turns and spawned subagents. It must be validated before rollout with synthetic classifier/tool-call checks so we know the selected workflow fires correctly and is inserted in the correct request location.
Key Implementation Changes
- Add a native workflow module under
codex-rs/core/src/workflows/with: WorkflowKind:debugging,feature_development,ui_creation,code_review,planning,testing,refactor,subagent_coordination,git_completion,safe_execution.ActiveWorkflow: primary workflow, optional secondary workflow, confidence, reason, injected text.classify_user_text(...): deterministic classifier using broad request classes, not one-off prompt hacks.build_workflow_developer_item(...): returns a compactdeveloperResponseItem.
- Insert workflow guidance transiently in the model request path, not in static prompt files:
- Use the per-turn sampling path in
codex-rs/core/src/codex.rs. - Build workflow state from the current
UserInputtext after user input is accepted. - Before
run_sampling_request(...), insert the workflow developer item intosampling_request_input. - Insert it before the latest user message in the prompt input, so it guides the current request without being persisted into conversation history.
- Do not add workflow text to
base_instructions,models-manager/prompt.md, or durableTurnContextItem.
- Apply to main model and subagents through the same path:
- Main turns already enter through
Op::UserInput. - Spawned agents call
AgentControl::spawn_agent_internal(...), then send the child’sinitial_operationthrough the same thread input path. - Because injection happens in the shared sampling path, both root sessions and subagents receive automatic workflow guidance.
- Guardian/reviewer subagents should be excluded unless explicitly safe, because guardian policy prompts are intentionally isolated.
- Add config defaults:
automatic_workflow_injection = trueautomatic_workflow_max_secondary = 1- Optional off switch in config/profile for debugging or ablation.
- Do not expose this as a user skill-selection feature by default.
- Keep injection compact:
- Max one primary and one secondary workflow.
- No full Superpowers text.
- No
SKILL.mdfile paths. - No user-facing mention of “Superpowers” in normal assistant output.
- Simple chat like “hi” gets no workflow injection.
Pre-Implementation Validation
Before implementing runtime injection, create a synthetic classifier validation fixture and script/check that verifies expected workflow selection.
- Add a fixture table with representative user prompts:
- “fix this compiler warning” ->
debugging - “build me a small local web app” ->
ui_creation+feature_development - “review my current changes” ->
code_review - “write a plan for this refactor” ->
planning - “add tests for this parser” ->
testing - “commit and push my changes” ->
git_completion - “dispatch agents to inspect this” ->
subagent_coordination - “delete this folder” ->
safe_execution - “hi” -> no workflow
- Add tests that assert:
- each synthetic prompt selects the expected workflow every time;
- no prompt selects multiple unrelated workflows;
- simple chat selects no workflow;
- code-review requests do not select feature-development;
- feature-build requests do not select code-review unless review language is present.
- Add prompt-shape tests that construct a synthetic
sampling_request_inputand verify: - workflow developer item is inserted before the latest user message;
- workflow item is not persisted to history;
- follow-up tool loops reuse the active workflow for the turn;
- accepted mid-turn user steering can reclassify or merge workflow guidance only when new user text materially changes the task.
Runtime Test Plan
- Unit tests:
- classifier fixture coverage for every workflow.
- injection helper places developer item before last user message.
- no injection for simple conversational input.
- no Superpowers path text appears in injected guidance.
- guardian subagent path does not receive workflow injection unless explicitly enabled.
- Integration-style tests:
- root
Op::UserInputgets workflow item in prompt input. - spawned agent
initial_operationgets workflow item through the same sampling path. - model request instructions remain unchanged except for transient workflow input item.
- LM Studio request capture shows the workflow developer item in the request body.
- conversation history/rollout does not permanently accumulate workflow guidance every turn.
- Manual validation scenarios:
- Greenfield UI app task should select
ui_creation+feature_development. - Compiler warning task should select
debugging. /reviewshould selectcode_review.- “hello” should produce no workflow injection.
- Spawned agent exploration should select
subagent_coordinationonly for the parent request; child agents classify their own assigned task.
Assumptions
- Workflow selection should be automatic and enabled by default.
- User-facing
/skills use ...is not part of the primary UX. - Superpowers is MIT licensed and can be used as source material, but v1 should use distilled original compact snippets rather than vendoring full skill docs.
- The correct insertion point is the shared per-turn sampling input in
codex-rs/core/src/codex.rs, not model catalog prompts or static base instructions. - The first implementation should prioritize deterministic keyword/class rules plus tests; semantic scoring can come later if the fixture matrix exposes gaps.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗