Using it from Python
Everything the command does is a library, and you can use the library without the command: make tasks, judge answers, check a contrast, hand tasks to another runner, read the published cards and read your own tools. This page shows each piece with a snippet you can run. The names on it are the package’s public API; a name that starts with an underscore is not.
Generating a task needs the tokenizer file, a 3.6 MB file the package fetches once, because it counts tokens in the way the published cards do. poisson-tasks init offers to fetch it, poisson-tasks doctor --fix fetches it, and so does:
python -m poisson_tasks.fetch_encodingOne task, and the verdict on an answer
Section titled “One task, and the verdict on an answer”An arm is one setting of one dial. ArmSpec names it with six fields: the knob, the level, the control (a higher level this arm stands in for, or none), the strictness, the split and the generator version. generate(arm, seed) returns the task: its prompts, the tools in the order the model sees them, the goal, a reference solution with what the domain returns for every call, the wrong answers it ships with, and the hashes that identify it. verify judges a transcript against it with no model.
from poisson_tasks.knobs import ArmSpecfrom poisson_tasks.tasks import FormatSpec, Turn, generate, verify
arm = ArmSpec("depth", 3, None, "strict", "eval", "0")bundle = generate(arm, seed=7)
turns = tuple(Turn("", (call,), "tool_calls") for call in bundle.reference_calls)turns += (Turn("Done.", (), "stop"),)
verdict = verify(bundle, turns, True, False, FormatSpec("direct", ()))assert verdict.label == "passed"print(bundle.task_id)print(verdict.label)42a193a13c6f97e5821f39591f826cd4072449a959782597cf1e3c76d6f986fapassedgenerate(arm, seed) returns a TaskBundle. The fields a user reads:
| field | what |
|---|---|
task_id | a digest over everything below; two equal ids are the same task |
arm_id | which arm generated it, e.g. depth:d3 |
seed, split | the draw. eval and train draw record ids from disjoint word lists, so no eval task can equal a train task |
system_prompt, prompt | what the model is shown. prompt is a string on a plain arm, and a message list on a control arm, which seeds history |
tools | the tool block, as JSON schemas, in the order the model sees them |
goal | (class, record_id, stage) — what counts as done |
reference_calls, reference_observations | one correct solution, and what the domain returns for it |
negative_controls | wrong answers, keyed by the outcome each should earn |
verifier | the strictness this task is judged under |
pins | the pin-ledger measurements taken off this bundle (see knobs-and-arms.md) |
engine_hash, generator_hash | what produced it. A task whose hashes differ from the ones a card recorded is not the task that card measured |
initial_state and expected_final_state are the ledger before and after, as sorted
(class, record_id, stage, token) rows.
verify(bundle, turns, ended_with_reply, turn_limit_hit, fmt) returns a Verdict, and is a pure function of those five arguments: no clock, no network, no model. (A sixth, optional spec, names the mock domain’s table; leave it out and the package’s own is used.) Its label is one of ten: passed when the ledger ends exactly at the goal with nothing else moved and the episode ended with a reply, and otherwise the first of malformed_call, turn_limit, overshoot, wrong_state and collateral_mutation that matches. verifier_error, replay_mismatch, api_error and wall_timeout are assigned by whatever ran the episode, never by verify. Every episode is judged strict and leaky at once (strict_label and leaky_pass). The task describes the domain and the verdicts.
poisson_tasks.outcomes.describe(label) gives each label’s plain sentence, the one verify and the cards print.
poisson-tasks verify does the same from the command line, with a task’s own answers or an attempt of yours (commands.md has its refusals). In this release it refuses tasks made on your own tools, which verify does not judge on its own yet: a run’s card judges those, by replay.
Arms by their id
Section titled “Arms by their id”A user names an arm by its id, such as depth:d3, and never by six fields. arms.arm_from_id is the inverse of knobs.arm_id; the other three fields are given by name.
from poisson_tasks import armsfrom poisson_tasks.knobs import arm_id
arm = arms.arm_from_id("depth:d3")print(arm)print(arm_id(arm))print(arms.arm_from_id("faults:f2", strictness="leaky", generator_version="0").strictness)ArmSpec(knob='depth', level=3, control=None, strictness='strict', split='eval', generator_version='3')depth:d3leakyAn id that is not written the way arm_id writes it (bogus:d1, or depth:d03 for depth:d3) is refused in one line that names what is wrong. The level is not judged here. The settings file takes only the levels the published cards measured; the export config takes any level the generator can make, and warns when no published card measured it, as for depth:d4.
A contrast, held to the pin ledger
Section titled “A contrast, held to the pin ledger”Two arms of one knob should differ in that knob and in nothing else. The pin ledger is thirty-one equalities across the arms of a contrast, measured on the generated tasks; knobs-and-arms.md lists them. check_pins runs them, and arms.describe_pins turns the report into one sentence.
from poisson_tasks import armsfrom poisson_tasks.knobs import check_pinsfrom poisson_tasks.tasks import generate
ids = ["depth:d1", "depth:d3", "depth:d8"]bundles = {i: generate(arms.arm_from_id(i, generator_version="0"), 404) for i in ids}report = check_pins(bundles)print(report.refused)print(arms.describe_pins(report))FalseThe depth contrast across depth:d1, depth:d3 and depth:d8 holds everything but the depth level fixed.A contrast that breaks a row is refused before any model runs: report.refused is true and report.violations names the rows.
Task ids and the generator version
Section titled “Task ids and the generator version”A task’s id is a hash of the task, the generator’s source and a short label, the generator version. Change any of them and the id changes. Two labels give the same prompt, tools, goal and reference solution, and different ids.
- The command and the settings file use the package’s default label,
arms.DEFAULT_GENERATOR_VERSION, and never ask.poisson-tasks generate --generator-versionand[tasks] generator_versionset another, for a library user who needs to reproduce tasks made under another label. - Both published cards were measured at label
"0", on an earlier build of the generator: their generator hash is that build’s at"0". The tasks they hold regenerate today with the same text, and with other ids, socard --publishedsays each card is not current for this install, and a run’s card cannot be read beside them. A later release measures the cards again on the current generator. - The examples use
"0", to match the label the cards carry. The export compares an arm with the arms a user gets today, at the default label, so anExportTasksetat"0"warns that no published card covers it as given; neither label gives the cards’ own ids under today’s generator.
Handing tasks to another runner
Section titled “Handing tasks to another runner”generate writes one JSON Lines file for every arm, one task per line, in the form poisson_tasks.export defines. A custom pipeline can read those files directly, and bundle_from_data turns a line back into the task generate returned.
poisson-tasks generate --arm depth:d1 --tasks-per-level 2ok generated 2 tasks: depth at 1, 2 tasks each, no model and no network pin ledger one arm, depth:d1: there is no contrast to check wrote tasks/depth-d1.jsonl (2 tasks)next: poisson-tasks runimport json
from poisson_tasks.export import ExportTaskData, bundle_from_data
with open("tasks/depth-d1.jsonl", encoding="utf-8") as lines: for line in lines: bundle = bundle_from_data(ExportTaskData.model_validate(json.loads(line))) print(bundle.arm_id, bundle.task_id[:12], len(bundle.tools), "tools")depth:d1 …depth:d1 …To run the tasks under verifiers yourself, ExportTaskset is a verifiers taskset over a declared list of seeds, scored by the generator’s own verifier, with the task’s tools served over MCP. verifiers-export.md has the names, the signals and the tool server.
import dataclasses
from poisson_tasks.export import ExportTaskset, ExportTasksetConfigfrom poisson_tasks.knobs import ArmSpec
arm = ArmSpec(knob="depth", level=3, control=None, strictness="strict", split="eval", generator_version="0")taskset = ExportTaskset(ExportTasksetConfig(arm=dataclasses.asdict(arm), seeds=[404, 55, 2121]))for task in taskset.load(): print(task.key[:12], len(task.data.tools), "tools")………The published cards, and what the knob probe found
Section titled “The published cards, and what the knob probe found”The cards ship inside the package. cards.published() lists them by their model’s short name, cards.recompute rebuilds one from its own records and says whether the rebuilt card is the stored one byte for byte and whether it is current for this install, and arms.knob_status() is the table of what the knob probe found, read from a file in the package.
from poisson_tasks import arms, cards
for card in cards.published(): made = cards.recompute(card) print(card.name, made.identical, made.current, made.records)
print(arms.knob_status()["knobs"]["history"]["says"])print(arms.SHIPPED_KNOBS)gpt-5-nano True False 4200qwen3-8b True False 4200ships: bites on gpt-5-nano; bites on Qwen3-8B('faults', 'history', 'shape')Measuring a model
Section titled “Measuring a model”poisson-tasks run and poisson-tasks card are built on four functions of poisson_tasks.calibration: run_arm runs one cell (one arm, one model), records_from_run turns a finished run folder into per-episode records, build_artifact computes every figure from them under a Provenance block, and render_document renders the card. build_artifact is where a card’s refusals are enforced (reading-a-card.md lists them).
A per-episode record (calibration.EpisodeRecord) carries two fields for the baddata and lagged dials, acted_on_bad_data and read_again_after_bad. Each is True or False on an arm of those dials above level 0, and None on every other arm and at level 0; a field that is None is left out of the record’s written line, so the episodes.jsonl of an older card keeps its bytes. A cell that has them carries acted_on_bad_data_count and acted_on_bad_data_share, read_again_after_bad_count and read_again_after_bad_share, which are the card’s two columns.
Your own tools
Section titled “Your own tools”own.read_tools reads an OpenAI tools file, an MCP tool list or an OpenAPI document (as bytes) into one form, refusing in one line each what it cannot use. own-tools.md describes what to do with the result.
import json
from poisson_tasks import own
tools = [ {"type": "function", "function": { "name": "get_order", "description": "Look up one order by its id.", "parameters": {"type": "object", "required": ["order_id"], "properties": {"order_id": {"type": "string", "minLength": 6, "maxLength": 6}}}}}, {"type": "function", "function": { "name": "refund_order", "description": "Refund part or all of an order.", "parameters": {"type": "object", "required": ["order_id", "amount"], "properties": {"order_id": {"type": "string", "minLength": 6, "maxLength": 6}, "amount": {"type": "number", "minimum": 0}}}}},]reading = own.read_tools(json.dumps(tools).encode("utf-8"), name="orders")print(own.summary(reading).splitlines()[0])2 tools: 0 read, 0 write, 2 not known (treated as write), 0 refusedown.summary counts what the file says. The command’s summary counts the set after what you declared in tasks.toml: own.apply_effects(reading.toolset, read=[...], write=[...]) is the set it counts, and a tool you declared as a read is a read there.
What produced a run
Section titled “What produced a run”poisson_tasks.provenance holds what a run records about what produced it (reading-a-card.md says what each value covers):
tool_spec_hash(data)is a tool file’s contract hash, from its bytes: the SHA-256 of the file as canonical JSON. A value JSON cannot carry is aValueErrorof one line naming its place. own-tools.md gives the rule.produced_by(plan)is the record a run of aconfig.Planby this install writes, as a dict with the same keys every time; a key that does not apply isNone.read_run(folder)is what a run folder recorded, as a card reads it (withresumed_with, the later versions that resumed it), orNonefor a run that recorded nothing.
from poisson_tasks import provenance
compact = b'{"tools":[{"name":"get_order","description":"Look up one order."}]}'spaced = b'{\n "tools": [\n {"description": "Look up one order.", "name": "get_order"}\n ]\n}\n'as_yaml = b"tools:\n - name: get_order\n description: Look up one order.\n"print(provenance.tool_spec_hash(compact))print(provenance.tool_spec_hash(spaced) == provenance.tool_spec_hash(as_yaml))try: provenance.tool_spec_hash(b'{"tools": [{"name": "get_order", "limit": NaN}]}')except ValueError as refused: print(refused)ee4cbdecd4814e38f8686b3bee522affbd4830b73963648374e659d5beb2c856True/tools/0/limit holds NaN, which JSON cannot carry; write it as JSON wouldThe examples, as source to read
Section titled “The examples, as source to read”The repository’s examples folder holds three short programs that use the library. They are not installed with the package; read them, and copy what you need. Each takes --help, and a mistaken argument gets one line.
| file | what it shows |
|---|---|
examples/one_task.py | one task, its reference solution, and the verdict on every answer it ships with (poisson-tasks generate --show and verify --self-check do the same from the command line) |
examples/a_contrast.py | the arms of a knob and the pin ledger over them, and a contrast the ledger refuses |
examples/calibration_card.py | a published card recomputed from its records (poisson-tasks card --published does the same) |