feat(agents): add Codex --loop=codex generator#40817
Conversation
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.
|
@microsoft-github-policy-service agree |
| return `[${values.map(value => tomlBasicString(value)).join(', ')}]`; | ||
| } | ||
|
|
||
| function tomlMultilineString(value: string): string { |
There was a problem hiding this comment.
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, '_'); |
There was a problem hiding this comment.
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, '_'); |
There was a problem hiding this comment.
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 = """`); |
There was a problem hiding this comment.
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".
Test results for "MCP"3 failed 7080 passed, 1068 skipped Merge workflow run. |
Test results for "tests 1"3 flaky41764 passed, 850 skipped Merge workflow run. |
Summary
CodexGeneratorto write.codex/agents/<name>.tomlfor planner, generator, healer using the Codex subagent schema (name,description,sandbox_mode,developer_instructions,[mcp_servers.playwright-test]withcommand/args/enabled_tools)codexto--loopchoices and abash-codextab indocs/src/test-agents-js.mdnamefield use underscored variants (e.g.playwright_test_planner.toml)Closes #40816
Docs renderer tab-label whitelist follow-up: microsoft/playwright.dev#2038