A role is a kind of agent: it names a default model and has a policy that says what it may do. You add a role
in nuramesh.yaml, then give an agent of that role a task in team.py. A new role can do nothing until its
policy allows it.
Prerequisites
Section titled “Prerequisites”- A
dev-teamfolder namedmy-teamthat runs (Start from a template). - An editor. The steps change two files:
my-team/nuramesh.yamlandmy-team/team.py.
-
Add the role to
org.rolesinnuramesh.yaml, after thedevopsrole.- {id: writer, name: Release note writer, default_model: fake/dev-1} -
Add an agent with that role to
org.agents.reports_toputs it under the Chief of Staff.- {id: wren, name: Wren (writer), role: writer, reports_to: chief} -
Allow what the role needs under
policies.policies. The writer calls the model and spends; nothing else.- role: writerrules:- {action: call_model, decision: allow, target: "fake/*"}- {action: spend, decision: allow} -
Give the agent a budget in the
budgetslist.- {id: wren-monthly, scope: agent, scope_id: wren, limit: {amount: "1.00", currency: USD}} -
Check the configuration.
Terminal window nuramesh validate my-team/nuramesh.yaml -
In
team.py, add the worker: the code that does the role’s work. Put it insidebuild, just above the linerun = env.run_id.def writer(task: Task, ctx: WorkContext) -> str:prompt = f"Write a one-line release note. {task.instructions}"reply = ctx.complete([Message(role="user", content=prompt)], max_output_tokens=100)return reply.response.text -
Add the task with its definition of done and a gate, just above
def files_of(.note = Task(id=f"{run}-release-note",run_id=run,title="Write the release note",instructions="Say what changed in add().",assignee="wren",definition_of_done=DefinitionOfDone(criteria=(Criterion(id="short", text="One line of at most 120 characters"),),gates=(GateSpec(id="one-line",kind=GateKind.RULE,checks=("short",),config={"rules": [{"criterion": "short","check": {"type": "length_between", "min": 10, "max": 120},}]},),),),) -
Register the worker and plan the task. Change the
workersline, and add one line to theplanlist.workers = {"dana": developer, "theo": tester, "omar": devops, "wren": writer}PlannedTask(note, depends_on=(f"{run}-fix-add",)), -
Script the fake model’s answer for the new task, so the team still runs with
--fake. Infake_model, above the lineif request.model == "reviewer-1"::if "release note" in " ".join(message.content for message in request.messages):return "Fixed: add() now returns the sum of its arguments." -
Run the team.
Terminal window nuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id role-1
Check it worked
Section titled “Check it worked”The report has a fourth task, done by the new agent, and a budget line for it:
[done] role-1-release-note (wren, attempts 1): Write the release note gate one-line (rule): passed by gate:ruleBudgets: wren-monthly (agent wren): spent 0.000240 of 1.00, reserved 0.000000Troubleshooting
Section titled “Troubleshooting”| You see | Do this |
|---|---|
validate says unknown_role or unknown_manager |
The agent names a role or a reports_to that does not exist. Check the ids in steps 1 and 2 |
The task is needs_human with note: policy refused |
The role’s policy does not allow the action. Step 3 is missing or its target does not match the model |
The task is needs_human with note: budget hard stop |
The agent’s budget cannot pay for the call: Set a hard budget |
A Python error names team.py |
Check the indentation of the pasted blocks: they sit inside build, four spaces in |
Next steps
Section titled “Next steps”- Teams and roles: how roles, agents and reporting lines fit together.
- Add an independent verifier: have another agent check the new role’s work.
- Autonomy policies: allow, ask and deny.
- Connect a model: give the role a real model.
Was this page helpful?