feat: open agent roles — accept AgentRole | str for custom roles - #1218
Open
colehurwitz wants to merge 3 commits into
Open
feat: open agent roles — accept AgentRole | str for custom roles#1218colehurwitz wants to merge 3 commits into
colehurwitz wants to merge 3 commits into
Conversation
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
marked this pull request as ready for review
August 12, 2026 19:02
|
The following files conflict:
Please rebase or merge |
Collaborator
|
@colehurwitz This branch has merge conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
_role_str(role: AgentRole | str) -> strhelper infactory/workflow/primitives.py— handles isinstance check once, used at every.valuecall siteAgentNode.role,AgentConfig.role, andGateNode.evaluator_rolefields toAgentRole | strfactory/agents/runner.py: project.factory/agents/→ user~/.factory/agents/→ builtinfactory/agents/prompts/"workspace-write"for unknown roles infactory/agents/plugin.py(with structlog warning instead of ValueError)model="sonnet",timeout=600) for unknown custom roles infactory/workflow/executor.pyfactory/workflow/tool.pyvia_parse_role()try/except onAgentRole().valuecall sites acrosscontext.py,skill_export.py,cli.py,verification.py,cycle_analyzer.pywith_role_str()definitions.pyto include custom role prompt file creationtests/test_open_agent_roles.pycovering helper, union types, three-tier resolution, sandbox default, JSON roundtrip, pool fallback, and regression checks