Skip to content
Docs
Request access

Add a custom role

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.

  • A dev-team folder named my-team that runs (Start from a template).
  • An editor. The steps change two files: my-team/nuramesh.yaml and my-team/team.py.
  1. Add the role to org.roles in nuramesh.yaml, after the devops role.

    - {id: writer, name: Release note writer, default_model: fake/dev-1}
  2. Add an agent with that role to org.agents. reports_to puts it under the Chief of Staff.

    - {id: wren, name: Wren (writer), role: writer, reports_to: chief}
  3. Allow what the role needs under policies.policies. The writer calls the model and spends; nothing else.

    - role: writer
    rules:
    - {action: call_model, decision: allow, target: "fake/*"}
    - {action: spend, decision: allow}
  4. Give the agent a budget in the budgets list.

    - {id: wren-monthly, scope: agent, scope_id: wren, limit: {amount: "1.00", currency: USD}}
  5. Check the configuration.

    Terminal window
    nuramesh validate my-team/nuramesh.yaml
  6. In team.py, add the worker: the code that does the role’s work. Put it inside build, just above the line run = 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
  7. 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},
    }
    ]
    },
    ),
    ),
    ),
    )
  8. Register the worker and plan the task. Change the workers line, and add one line to the plan list.

    workers = {"dana": developer, "theo": tester, "omar": devops, "wren": writer}
    PlannedTask(note, depends_on=(f"{run}-fix-add",)),
  9. Script the fake model’s answer for the new task, so the team still runs with --fake. In fake_model, above the line if 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."
  10. Run the team.

    Terminal window
    nuramesh try my-team --fake --approve-as human:you --allow-unsandboxed --run-id role-1

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:rule
Budgets:
wren-monthly (agent wren): spent 0.000240 of 1.00, reserved 0.000000
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

Was this page helpful?