Skip to content

hylo.codeagents.research

Package: hylo-code-agents · Core contracts

research

Research sessions (RFC-0006 part 5): a model develops a program on development cases, then it is frozen.

The model works in one persistent namespace across episodes of the benchmark's search split (development cases). Besides the toolkit (robot, on the live episode) it has:

cases            the development cases: [{"case": i, "instruction": ...}]
reset(case=None) end the live episode, return its outcome (success, steps, reason), start `case` (default: again)
submit(source=None)  validate a program defining solve(robot) (default: the imports, functions and constants the
                 blocks defined) and run it, without the model (code.program), on a
                 fresh episode of every development case; returns each case's outcome and printed output
finish()         end the session

The submission with the most development successes (the earliest on a tie) is frozen into a sealed program artifact (provenance: the search split only) and becomes a Candidate(kind="code") whose patch sets agent.type: code.program and the artifact: from there it is an ordinary candidate (search_val, gate, held-out, approval). The model never sees anything but development cases. Budgets: turns, model tokens and cost, resets, submissions. Everything goes to the session directory:

log.jsonl            one record per turn, reset, submission and the end (images as PNG files under images/)
live/                traces of the live episodes
submissions/sub-NN/  solve.py, results.json and the traces of each submission's runs
frozen/<name>/       the sealed program artifact
summary.json         turns, usage, dev outcomes per submission, the frozen program and the candidate

DEV_SPLIT module-attribute

DEV_SPLIT = 'search'

SYSTEM module-attribute

SYSTEM = 'You are developing a Python program that makes a robot solve a family of tasks. You experiment on\ndevelopment cases, then submit programs; the best submission is frozen and later evaluated on unseen cases of the\nsame family that you will never see.\n\n{robot}\n\nToolkit API (`robot`, acting on the live development episode):\n{api}\n\n{rules}\n\nResearch functions (in your namespace):\n- `cases`: the development cases, a list of {{"case": i, "instruction": ...}}. A live episode of one case is running.\n- `reset(case=None)`: ends the live episode and returns its outcome {{"case", "success", "steps", "reason"}}, then\n  starts case `case` (default: the same case again). Your variables survive resets.\n- `submit(source=None)`: submits a program that defines `solve(robot)`; it is validated, then run without you on a\n  fresh episode of every development case. `submit()` with no argument submits what your blocks defined at the top\n  level: every import, function definition and constant assignment (the latest of each name), which must include\n  `solve(robot)`. Or pass the complete program as a string. The program does not see your other variables. Defining\n  `solve` does not submit it: only submit() evaluates it. Returns {{"submission", "successes", "cases", "results": [per case: success,\n  steps, reason, output, error]}}. A program can call finish() to end its episode early; returning also ends it.\n- `finish()`: ends the session. The submission with the most development successes is frozen.\n\nWrite general code: read the instruction from robot.status()["instruction"], measure the scene every time, and never\nhard-code positions seen in one case.{skills}{demo}{parent}{guidance}'

ResearchConfig

Bases: Contract

dev class-attribute instance-attribute

dev: int = Field(default=6, ge=1)

budget class-attribute instance-attribute

budget: Budget = Field(default_factory=lambda: Budget(turns=40, resets=30, submits=6))

tools class-attribute instance-attribute

tools: str | dict[str, Any] | None = None

block_timeout_s class-attribute instance-attribute

block_timeout_s: float = 60.0

program_timeout_s class-attribute instance-attribute

program_timeout_s: float = 300.0

act_wait_s class-attribute instance-attribute

act_wait_s: float = 86400.0

reply_tokens class-attribute instance-attribute

reply_tokens: int | None = None

max_history_turns class-attribute instance-attribute

max_history_turns: int = 30

max_context_chars class-attribute instance-attribute

max_context_chars: int | None = 80000

min_dev_successes class-attribute instance-attribute

min_dev_successes: int = 1

family class-attribute instance-attribute

family: str | None = None

program_params class-attribute instance-attribute

program_params: dict[str, Any] = Field(default_factory=dict)

demonstration class-attribute instance-attribute

demonstration: str | None = None

parent_program class-attribute instance-attribute

parent_program: str | None = None

guidance class-attribute instance-attribute

guidance: str | None = None

auto_submit class-attribute instance-attribute

auto_submit: bool = False

skills class-attribute instance-attribute

skills: str | dict[str, Any] | None = None

max_case_output class-attribute instance-attribute

max_case_output: int = 1200

ResearchSession

ResearchSession(cfg: ExperimentConfig, model: str | Mapping[str, Any] | ChatModel, out_dir: str | Path, *, config: ResearchConfig | Mapping[str, Any] | None = None, name: str | None = None, log: Any = None)

cfg instance-attribute

cfg = cfg

rc instance-attribute

rc = config if isinstance(config, ResearchConfig) else ResearchConfig.model_validate(dict(config or {}))

model instance-attribute

model = build_chat(model)

out instance-attribute

out = Path(out_dir)

name instance-attribute

name = name or f'{cfg.name}-research-{uuid.uuid4().hex[:6]}'

say instance-attribute

say = log or (lambda msg: None)

submissions instance-attribute

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

resets instance-attribute

resets = 0

finished instance-attribute

finished = False

frozen instance-attribute

frozen: dict[str, Any] | None = None

summary instance-attribute

summary: dict[str, Any] = {}

reset

reset(case: int | None = None) -> dict[str, Any]

submit

submit(source: str | None = None) -> dict[str, Any]

finish

finish() -> str

best

best() -> dict[str, Any] | None

run

run() -> dict[str, Any]

write_summary

write_summary() -> None

family

family() -> str

candidate

candidate(parent_id: str | None = None, generator: str | None = None) -> Candidate | None

The frozen program as a code candidate (None when nothing was frozen).

evaluate

evaluate(splits: list[str], *, with_parent: bool = False) -> dict[str, Any]

Run the frozen program on other splits (search_val, gate, heldout) and record the results in summary.json.

dev_cases

dev_cases(bench: Any, n: int) -> list[TaskInstance]

The first n instances of the search split, interleaved across tasks (seed 0 of every task, then seed 1, ...).