Skip to content

feat(agents): add Codex --loop=codex generator#40817

Open
0xharkirat wants to merge 2 commits into
microsoft:mainfrom
0xharkirat:feat-codex-agents
Open

feat(agents): add Codex --loop=codex generator#40817
0xharkirat wants to merge 2 commits into
microsoft:mainfrom
0xharkirat:feat-codex-agents

Conversation

@0xharkirat
Copy link
Copy Markdown

@0xharkirat 0xharkirat commented May 13, 2026

Summary

  • Add CodexGenerator to write .codex/agents/<name>.toml for planner, generator, healer using the Codex subagent schema (name, description, sandbox_mode, developer_instructions, [mcp_servers.playwright-test] with command/args/enabled_tools)
  • Add codex to --loop choices and a bash-codex tab in docs/src/test-agents-js.md
  • Codex's spawn router rejects hyphenated names, so the filename and name field use underscored variants (e.g. playwright_test_planner.toml)

Closes #40816

Docs renderer tab-label whitelist follow-up: microsoft/playwright.dev#2038

Generates `.codex/agents/<name>.toml` for planner, generator, and healer
per the Codex subagent schema (name, description, sandbox_mode,
developer_instructions, mcp_servers.playwright-test with command/args
and enabled_tools). Mirrors the existing Claude/Opencode branches.
Codex's spawn router rejects hyphenated agent names with
`error=unknown agent_type 'playwright-test-planner'`. Replace
hyphens with underscores for both the .codex/agents/*.toml
filename and the `name` field. The Claude/Opencode agent ids
keep their original hyphenated form.
@0xharkirat
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

return `[${values.map(value => tomlBasicString(value)).join(', ')}]`;
}

function tomlMultilineString(value: string): string {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these utils should go into packages/isomorphic/stringUtils.ts


await fs.promises.mkdir('.codex/agents', { recursive: true });
for (const agent of agents) {
const codexName = agent.name.replace(/-/g, '_');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we don't do this for other agents, why here?

: '';

// Codex agent identifiers must be underscored — hyphens cause `unknown agent_type` errors on spawn.
const codexName = agent.name.replace(/-/g, '_');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The same agent.name.replace(/-/g, '_') is duplicated in init() above. The filename and the name field must stay in sync — extract a tiny toCodexName(agent) helper (or compute it once in init() and pass it through) so the two can't drift.

const plannerToml = fs.readFileSync(path.join(agentsDir, 'playwright_test_planner.toml'), 'utf-8');
expect(plannerToml).toContain(`name = "playwright_test_planner"`);
expect(plannerToml).toContain(`[mcp_servers.playwright-test]`);
expect(plannerToml).toContain(`developer_instructions = """`);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nothing here exercises enabled_tools — the whole tool-filter loop in agentSpec() is uncovered. Worth adding an assertion that the planner's TOML contains enabled_tools = [...] with a known entry like "planner_save_plan".

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

3 failed
❌ [chrome] › mcp/annotate.spec.ts:57 › should capture multiple screenshots in one annotation @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:110 › should abort annotation when last screenshot is removed @mcp-windows-latest-chrome
❌ [chrome] › mcp/annotate.spec.ts:398 › should cancel browser_annotate when the MCP client disconnects @mcp-windows-latest-chrome

7080 passed, 1068 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 1"

3 flaky ⚠️ [chromium-library] › library/video.spec.ts:719 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/inspector/cli-codegen-3.spec.ts:224 › cli codegen › should generate frame locators (4) `@firefox-ubuntu-22.04-node20`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:185 › should show snapshots for steps `@windows-latest-node20`

41764 passed, 850 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add Codex (--loop=codex) support to init-agents

2 participants