Skip to content

Pillar 1: The Role Pattern

OSTwin’s first architectural pillar inverts the traditional approach to AI agents. Instead of coding each agent as a separate program, every role in the system is a configuration directory executed by a single, universal runner.

“Adding a new role requires zero lines of code.”

Role as a Config Directory

Each role is a directory under .agents/roles/ containing exactly two files:

.agents/roles/engineer/
role.json # Machine-readable config
ROLE.md # Identity prompt (personality + constraints)

No Python class. No TypeScript module. No compilation step. The role is its directory.

role.json Schema

The role.json file declares everything the runner needs to configure the agent session.

FieldTypeDescription
namestringRole identifier (e.g. "engineer")
display_namestringHuman-readable label
descriptionstringOne-line purpose statement
modelstringPreferred model ID (e.g. "claude-sonnet-4-20250514")
providerstringLLM provider ("anthropic", "openai", "vertex")
no_mcpboolIf true, launch without MCP servers (saves tokens)
skill_refsstring[]Skills this role should always have access to
temperaturefloatSampling temperature override
max_tokensintMax output tokens per turn

ROLE.md Identity Prompt

The ROLE.md file is a markdown document injected as the system prompt. It defines:

  • Who the agent is — its expertise, personality, communication style
  • What it must do — responsibilities, deliverables, quality standards
  • What it must not do — boundaries, anti-patterns, escalation triggers
# Engineer
You are a senior software engineer working inside a war-room.
Your job is to implement tasks assigned by the manager, write
production-quality code, and deliver structured done reports.
## Constraints
- Never modify files outside your war-room's scope
- Always run tests before reporting done
- Escalate architectural questions to the architect role

Flexible Role Composition

The concept of a “Role” in OSTwin is entirely flexible. A role is not defined by hard-coded capabilities but rather by the combination of its Identity (Prompt), Skills, and MCP Servers.

You can completely redefine what an “engineer” or “qa” role can accomplish simply by adjusting their role.json configuration:

  1. Skills (Expertise): Adding or removing skill_refs changes the specialized workflows the role knows how to execute.
  2. MCP (Tools): Adding or removing mcp_refs changes the external systems, APIs, or tools the role can interact with.

This compositional approach means you can spawn infinite variations of roles—like a frontend-engineer with Figma MCP tools or a security-qa with specialized scanning skills—without writing a single line of agent orchestration code.

5-Tier Role Discovery

When roles/_base/Invoke-Agent.ps1 resolves a role, it searches five locations in priority order:

PriorityLocationScope
1.agents/war-rooms/{room}/roles/{role}/Room-local override
2.agents/roles/{role}/Project-level role
3~/.agents/roles/{role}/User-global role
4Built-in defaultsShipped with OSTwin
5Registry lookupDynamic resolution

This means you can override the engineer role for a single war-room without affecting any other room.

Role Registry

The file registry.json (~700 lines) catalogs every known role with metadata for discovery and assignment. The manager agent reads this registry when deciding which roles to assign to a war-room.

{
"engineer": {
"description": "Implements features, fixes bugs, writes tests",
"skills": ["implement-epic", "fix-from-qa", "write-tests"],
"model": "claude-sonnet-4-20250514"
},
"qa": {
"description": "Reviews deliverables, runs test suites, posts verdicts",
"skills": ["review-epic", "review-task", "build-verify"],
"model": "claude-sonnet-4-20250514"
}
}

Model Resolution Priority

The model used for a given agent invocation is resolved through four levels:

PrioritySourceExample
1War-room config.json overrideRoom needs GPT-4o for vision tasks
2role.json preferenceArchitect prefers Opus for deep reasoning
3Plan-level defaultPlan specifies Sonnet for cost control
4System defaultFalls back to claude-sonnet-4-20250514

Dynamic Role Creation

New roles can be created at runtime by the create-role skill:

  1. The manager identifies a capability gap (e.g., “we need a database specialist”)
  2. It invokes the create-role skill with a description
  3. The skill generates role.json + ROLE.md in the project’s .agents/roles/ directory
  4. The new role is registered in registry.json
  5. Future war-rooms can immediately assign the new role

No restart. No deployment. No code change.

Current Roles

OSTwin ships with 8 core roles and supports 50+ community-contributed roles:

Core roles: manager, engineer, qa, architect, game-engineer, game-designer, game-qa, reporter

Community roles include: narrative-designer, ux-researcher, macos-automation-engineer, game-ui-analyst, game-architect, audit, and many more domain-specific specialists.

Why This Matters

Key Source Files

FilePurpose
.agents/roles/*/role.jsonRole configuration
.agents/roles/*/ROLE.mdIdentity prompt
.agents/roles/registry.jsonRole catalog (~700 lines, 20+ roles)