Skip to content

feat: open agent roles — accept AgentRole | str for custom roles - #1218

Open
colehurwitz wants to merge 3 commits into
mainfrom
factory/run-0d52fea0
Open

feat: open agent roles — accept AgentRole | str for custom roles#1218
colehurwitz wants to merge 3 commits into
mainfrom
factory/run-0d52fea0

Conversation

@colehurwitz

Copy link
Copy Markdown
Collaborator

Changes

  • Add _role_str(role: AgentRole | str) -> str helper in factory/workflow/primitives.py — handles isinstance check once, used at every .value call site
  • Widen AgentNode.role, AgentConfig.role, and GateNode.evaluator_role fields to AgentRole | str
  • Three-tier prompt resolution in factory/agents/runner.py: project .factory/agents/ → user ~/.factory/agents/ → builtin factory/agents/prompts/
  • Default sandbox mode "workspace-write" for unknown roles in factory/agents/plugin.py (with structlog warning instead of ValueError)
  • Pool fallback (model="sonnet", timeout=600) for unknown custom roles in factory/workflow/executor.py
  • JSON roundtrip safety in factory/workflow/tool.py via _parse_role() try/except on AgentRole()
  • Replace all .value call sites across context.py, skill_export.py, cli.py, verification.py, cycle_analyzer.py with _role_str()
  • Update create mode builder checklist in definitions.py to include custom role prompt file creation
  • Comprehensive test suite in tests/test_open_agent_roles.py covering helper, union types, three-tier resolution, sandbox default, JSON roundtrip, pool fallback, and regression checks

colehurwitz and others added 3 commits August 12, 2026 13:31
Widen AgentNode.role, AgentConfig.role, and GateNode.evaluator_role to
accept plain strings alongside the AgentRole enum, enabling custom agent
roles without modifying factory source code.

Key changes:
- Add _role_str() helper in primitives.py; use at all .value call sites
- Three-tier prompt resolution: project → user (~/.factory/agents/) → builtin
- Default sandbox mode "workspace-write" for unknown roles (with warning)
- Pool fallback (model=sonnet, timeout=600) for unknown roles in executor
- JSON roundtrip safety in tool.py via try/except on AgentRole()
- Create mode checklist updated to include custom role prompt creation
- Comprehensive test suite (tests/test_open_agent_roles.py)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… handling

- Remove old 4-param _find_loop_context (shadowed by new 5-param version)
- Update _format_node_task call to pass topo order argument
- Use _role_str(node.role) instead of node.role.value for custom role support
- Remove extraneous f-string prefix on non-interpolated string

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nings

- CLAUDE.md: update agent prompt resolution from 'two-tier lookup' to
  'three-tier lookup' (project → user-level → factory default), note
  that roles accept AgentRole enum values or custom strings
- factory/cli/_ceo_helpers.py: remove extraneous f-string prefixes on
  lines 130-131 (ruff F541)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@colehurwitz
colehurwitz marked this pull request as ready for review August 12, 2026 19:02
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown

⚠️ Merge conflict detected with main

The following files conflict:

  • factory/agents/plugin.py
  • factory/agents/runner.py
  • factory/workflow/context.py
  • factory/workflow/definitions.py
  • factory/workflow/executor.py
  • factory/workflow/tool.py
  • tests/test_plugin_agents.py

Please rebase or merge main to resolve.

@osilkin98

Copy link
Copy Markdown
Collaborator

@colehurwitz This branch has merge conflicts

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.

2 participants