Skip to content

hylo.codeagents.roles

Package: hylo-code-agents · Core contracts

roles

Role campaigns (RFC-0008 part 9): a coordinator works through a set of tasks with worker and verifier roles over a tool surface, keeps a ledger of every tool call, and admits skills only after an independent replay.

hylo roles run CAMPAIGN.yaml [--model ollama:qwen3.5:35b-a3b] [--out runs/roles/NAME]
hylo roles status OUT

A campaign file lists tasks, each a stage (a hylo.stage/v0.1 file the task starts from), a request for the worker, a goal (a check predicate) and a partition:

  dev       pending -> working -> verifying -> done        a worker session works until its check holds
                              \-> retrying -> blocked       one retry, with the failure reasons and matching skills
            after a dev task is done, its worker's successful tool calls become a proposed skill (a recipe) with the
            failure signature the task started with; a verifier (no model) replays the recipe on a fresh copy of the
            task and checks the goal, at most twice; only a passing replay promotes the skill into the library
  heldout   pending -> heldout -> done | failed            evaluated last, with the library frozen; never used to
            propose or verify skills, and never shown to a dev worker

Rules: every task runs on its own copy of its stage (the campaign's stage root), so tasks never see each other's changes; every tool call goes into ledger/<task>/<run>.jsonl (tool, argument digest, ok, error code, receipt status) and counts against the task's budget (max_tool_calls; the call that crosses it fails with campaign_budget_exceeded); the coordinator takes the pending dev task with the fewest goal atoms first. Progress is written to status.json after every transition.

TRANSITIONS module-attribute

TRANSITIONS = {'pending': {'working', 'heldout'}, 'working': {'verifying', 'retrying', 'blocked'}, 'retrying': {'verifying', 'blocked'}, 'verifying': {'done', 'blocked'}, 'heldout': {'done', 'failed'}, 'done': set(), 'blocked': set(), 'failed': set()}

Ledger

Ledger(inner: Surface, path: Path, max_calls: int | None)

A surface wrapper that records every call of one run and enforces the call budget.

calls instance-attribute

calls: list[dict[str, Any]] = []

call

call(name: str, args: Mapping[str, Any] | None) -> ToolReply

RoleCampaign

RoleCampaign(spec: Mapping[str, Any], out: str | Path, model: ChatModel | None, surface_factory: Callable[[str, str], Surface] | None = None)

stage_root instance-attribute

stage_root = self.out / 'stages'

surface_name instance-attribute

surface_name = spec.get('surface', 'mujoco.world')

factory instance-attribute

factory = surface_factory or (lambda root, stage: registry.build('surfaces', {'type': self.surface_name, 'params': {'root': root, 'stage': stage}}))

library instance-attribute

library = SkillLibrary(str(self.out / 'skills'))

tasks instance-attribute

tasks = {t['id']: {**t, 'state': 'pending', 'runs': [], 'partition': t.get('partition', 'dev')} for t in spec['tasks']}

budget instance-attribute

budget = int(spec.get('max_tool_calls', 60))

base instance-attribute

base = Path(spec.get('base_dir', '.'))

events instance-attribute

events: list[dict[str, Any]] = []

transition

transition(tid: str, state: str, **info: Any) -> None

save

save() -> None

fresh

fresh(tid: str, run: str) -> tuple[Surface, str]

A new copy of the task's stage (its own stage name) and a surface on it.

check

check(surface: Surface, goal: Mapping[str, Any]) -> dict[str, Any]

worker

worker(tid: str, run: str, extra: str = '', frozen: bool = False) -> dict[str, Any]

verifier

verifier(tid: str, skill: Skill, tries: int = 2) -> dict[str, Any]

Replay the recipe on fresh copies of a dev task (no model) and check the goal.

run

run() -> dict[str, Any]

goal_atoms

goal_atoms(goal: Mapping[str, Any]) -> int

recipe_from

recipe_from(calls: list[dict[str, Any]]) -> list[dict[str, Any]]

The successful acting calls of a run, in order, without generation-bound fields (they are re-read on replay).

replay

replay(surface: Surface, steps: list[dict[str, Any]]) -> list[dict[str, Any]]

Run a recipe: stage edits against the current revision, actions against the current generation.

main

main(argv: Sequence[str] | None = None) -> int

role campaigns: worker and verifier sessions over dev and held-out tasks, skills by replay