Reference for coding agents
The order of commands and the fields of each record an experiment needs. For the coding agent that runs the experiment.
This page is for the coding agent. The setup prompt and the neatlogs-local-testing skill describe the same steps; this page gives the exact commands, record fields and examples. Read --help of the installed CLI before you use a command. If a command or flag is missing, report the installed version (neatlogs --version, 0.2.3 or later is needed); don't invent syntax. All flags are in the CLI command reference.
Bind every command
Use the same binding on every project command:
neatlogs --host <dashboard-url> --profile <profile> --credential-source profile --project <project-id> --json <command>The host is the dashboard address (https://app.neatlogs.com or https://eu.app.neatlogs.com), not the trace ingest address. The examples below leave the binding out to stay short.
Set these in every shell and child process once the IDs exist:
| Variable | Set from | Why |
|---|---|---|
NEATLOGS_LOCAL_EXPERIMENT_ID | experiments create | Links your CLI activity, failures and retries to the experiment page. |
NEATLOGS_LOCAL_ROUND_ID | experiments round | Links activity to the round. A decision recorded while it is set belongs to that round. |
Command order
| Step | Command |
|---|---|
| 1. Check the CLI | neatlogs --version, neatlogs experiments --help, neatlogs experiments record --help (must list --source-file) |
| 2. Check the sign-in | --project <project-id> --json whoami, compare only the six resource scopes in data.credential.scopes (offline_access is login-only and never returned) (see Sign-in permissions) |
| 3. Keep the connection open | neatlogs local connect in a second terminal, same binding |
| 4. Create the experiment | experiments create --name "<name>" --goal "<goal>" --idempotency-key <uuid> |
| 5. Say what you are doing | experiments status --aim "<aim>" --task "<task>" --step "<step>", whenever your work changes |
| 6. Cases | datasets from-traces --body-stdin (recorded) or datasets create --body-stdin (input-only); add --standalone for any dataset after the first |
| 7. Judge | evaluators create --body-stdin |
| 8. Questions | evals create --body-stdin, then evals form set <evaluation-id> --body-stdin, then read formVersionId from evals form management <evaluation-id> |
| 9. Detections | detections list --status active; a new one only if asked: see Detections |
| 10. Save each part, then the setup | experiments record --experiment <id> --body-stdin: kind resource for each part, then kind setup |
| 11. Create a round | experiments round --experiment <id> --name "<name>" --hypothesis "<text>" --variants '<json>' |
| 12. Capture A, run A | kind preparation with --source-file <paths> (variant A) before you edit, then evals run with --variant A |
| 13. Change the code, capture B, run B | Same --source-file paths after the edit (variant B), then evals run with --variant B |
| 14. Queue detections | kind checks for each run, then wait until every check has finished |
| 15. Compare | evals compare <run-A> <run-B> |
| 16. Record the result | kind result with the verdict and decision continue or finish |
Before you send any body, read the command's --help. Pass --experiment to experiments round even when NEATLOGS_LOCAL_EXPERIMENT_ID is set. Save every --idempotency-key and requestKey before you send, and reuse it only to retry the same request.
Cases
Recorded cases, from traces you verified:
{"name": "Support agent: refund requests", "description": "Four recorded requests",
"traceIds": ["<trace id>", "<trace id>"]}Input-only cases (datasets create); each case has an input your task understands:
{"name": "Support agent: refund requests · inputs",
"cases": [{"input": {"message": "Can I return a used kettle?"}, "tags": ["refund"]}]}Read the version and case IDs with neatlogs datasets cases <dataset-id> --version-id <version-id> (--version-id is required). If saving recorded cases is refused with GRADING_EVIDENCE_INCOMPLETE, switch to input-only cases at once and record a decision: see Troubleshooting.
Questions and judge
The judge (evaluators create) needs an explicit model from an active model connection:
{"name": "Support judge", "type": "llm_judge",
"modelProvider": "<provider>", "modelName": "<model>",
"systemPrompt": "You grade one reply of the support agent ...",
"outputSpec": [{"key": "cites_policy", "label": "The reply cites the refund policy", "scoreType": "boolean", "required": true}]}The eval that holds the questions (evals create):
{"name": "Support replies", "description": "Pass/fail checks on one reply",
"type": "human", "traceSource": "existing", "sendFrequency": "manual"}The questions (evals form set <evaluation-id> --body-stdin), each assigned to the judge:
{"name": "Support replies",
"questions": [{"answerType": "multiple_choice", "questionText": "Does the reply cite the refund policy?",
"sortOrder": 0, "isRequired": true, "options": {"options": ["Pass", "Fail"], "hasOther": false},
"passRule": {"equals": "Pass"}, "assignedEvaluators": ["ai:<judge-id>"]}]}The id that form set returns is the form ID, not the form version ID. Read formVersionId from evals form management <evaluation-id>. evals assistant chat only drafts suggestions; it does not save a form.
Detections
Reuse active detections that fit the goal: neatlogs detections list --status active --search "<words>". Choose one list for both versions.
Create a new detection only for a check the user asked for:
neatlogs detections authoring prepare --request-stdinprepares and previews an inactive draft. Send only the human draft body; do not addthread_id,request_idorrequirement_id(Curator-only fields that human sign-in rejects). Read the request shape with--help.neatlogs detections authoring showreturns the revision and fingerprints to review. Stop here and wait for the user's explicit confirmation of that exact inactive draft revision. To fix a draft, revise the same draft (detections authoring revise); never create another.- Only after that confirmation, run
neatlogs detections authoring commit --draft-id <id> --revision <n> --fingerprint <hash> --approval-fingerprint <hash> --confirm <draft-id>approves that exact revision and turns it on. This needsdetection:manage(project Admin), which does not replace the user's confirmation. If confirmation or permission is missing, leave the draft inactive, record a decision and continue with the existing active detections.
Never create a detection per case, per version or per retry.
Record kinds
All records go through neatlogs experiments record --experiment <id> --body-stdin, with the JSON body on stdin.
| Kind | Required fields | Notes |
|---|---|---|
resource | role (cases, questions, judge, detection), resource {kind, id, revision, disposition, reason} | Cases add datasetVersionId, caseIds, trials. Questions add formVersionId. No requestKey. |
setup | setup {datasetVersionId, caseIds, trials, formVersionId, evaluatorIds, detectionIds, resources} | disposition is created or reused. Freezes the setup. |
preparation | roundId, variant (A or B), preparation {state: preparing, ready or failed, message} | Send with --source-file. Send again before every run or retry. No requestKey. |
checks | roundId, runId, requestKey | Queues the detections for one run. |
decision | requestKey, decision {topic, planned, chosen, reason, givenUp} | topic: dataset, cases, judge, questions, detection, trace_evidence, attempt, measure, goal, other. chosen under 80 characters, reason under about 280. |
result | roundId, result {runA, runB, outcome, decision, verdict, reason} | See The result. No requestKey. |
Only decision and checks take a requestKey. Each requestKey is a new UUID.
One resource record per part, each sent on its own (use the detection's own revision from detections get):
{"kind": "resource", "role": "cases",
"resource": {"kind": "dataset", "id": "<dataset id>", "revision": "<version id>",
"disposition": "created", "reason": "4 realistic refund requests"},
"datasetVersionId": "<version id>", "caseIds": ["<case id>", "<case id>"], "trials": 1}
{"kind": "resource", "role": "questions",
"resource": {"kind": "evaluation", "id": "<evaluation id>", "revision": "<form version id>",
"disposition": "created", "reason": "Three pass/fail checks from the goal"},
"formVersionId": "<form version id>"}
{"kind": "resource", "role": "judge",
"resource": {"kind": "evaluator", "id": "<judge id>", "revision": "1",
"disposition": "created", "reason": "Judge on the project's model connection"}}
{"kind": "resource", "role": "detection",
"resource": {"kind": "detection", "id": "<detection id>", "revision": "<revision>",
"disposition": "reused", "reason": "Agent Execution Error, as the user asked"}}The setup, with the same four resources:
{"kind": "setup",
"setup": {"datasetVersionId": "<version id>", "caseIds": ["<case id>", "<case id>"], "trials": 1,
"formVersionId": "<form version id>", "evaluatorIds": ["<judge id>"], "detectionIds": ["<detection id>"],
"resources": [{"kind": "dataset", "id": "<dataset id>", "revision": "<version id>", "disposition": "created", "reason": "..."},
{"kind": "evaluation", "id": "<evaluation id>", "revision": "<form version id>", "disposition": "created", "reason": "..."},
{"kind": "evaluator", "id": "<judge id>", "revision": "1", "disposition": "created", "reason": "..."},
{"kind": "detection", "id": "<detection id>", "revision": "<revision>", "disposition": "reused", "reason": "..."}]}}trials is how many times each case runs per version; use 1 unless answers vary between runs (evals run --trials defaults to 1). Read every ID from the --json output of the command that created it.
A decision:
{"kind": "decision", "requestKey": "<new uuid>",
"decision": {"topic": "dataset", "planned": "Pin the 4 recorded cases",
"chosen": "Input-only cases of the same 4 topics",
"reason": "Saving the recorded cases was refused with GRADING_EVIDENCE_INCOMPLETE",
"givenUp": "The recorded answers are not graded as a reference"}}Checks for one run:
{"kind": "checks", "requestKey": "<new uuid>", "roundId": "<round id>", "runId": "<run id>"}To see whether detections have finished, read runAttempts[].detectionChecks in neatlogs --json experiments get <experiment-id>. Wait until every check has a final result; a missing result is not a pass.
Rounds and code
--variants takes A and B, each with a name and the exact changes:
{"A": {"name": "current", "changes": "No change: current model and prompt"},
"B": {"name": "cheaper model", "changes": "Model switched to a smaller one; prompt unchanged"}}A preparation, sent with the files the change touches:
echo '{"kind": "preparation", "roundId": "<round id>", "variant": "A",
"preparation": {"state": "ready", "message": "A prepared from the current code"}}' \
| neatlogs experiments record --experiment "$NEATLOGS_LOCAL_EXPERIMENT_ID" --body-stdin \
--source-file src/agent.ts prompts/system.mdUse paths relative to the project folder and the same paths for A and B. A file that exists on one side only records an addition or deletion. Never select secrets or the whole repository. Use --data-only on experiments round only when the user asks for a comparison without code tracking.
Run a version
evals run runs a task file on every pinned case. The task file is a JavaScript module (.js, .mjs, .cjs) that exports task(input, context) and returns what the judge grades, or a Python file run through the Neatlogs Python SDK. Read parameters with context.param(name, fallback). The task must call your real agent with its own tools; never return saved answers.
neatlogs evals run eval-task.mjs --dataset <dataset-id> --version-id <version-id> \
--form-version-id <form-version-id> --evaluator-id <judge-id> --trials 1 \
--experiment "$NEATLOGS_LOCAL_EXPERIMENT_ID" --round "$NEATLOGS_LOCAL_ROUND_ID" \
--variant A --attempt 1 --label round1-A --state .run-state/round1-A.jsonUse the same dataset version, cases, trials, form version and judge for A and B. Keep one private --state file per run. Start a run in the background and wait for it to exit; don't poll in a sleep loop. If you must poll, read the saved run at most every 30 seconds. The output also lists run IDs of earlier rounds: take the ID of the run you just started.
The result
| Field | Values |
|---|---|
outcome | goal_met, goal_not_met, tradeoff, incomplete |
decision | continue (another round) or finish. This field is the round's next step, not the decision record kind. |
verdict | b_wins, keep_a, tie, inconclusive. An incomplete outcome allows only inconclusive. |
reason | Markdown, at most 2000 characters. First line: the verdict in one plain sentence. Then bold sections What changed, What we saw (numbers for each side), Next. End What we saw with Decided on: <measures in order>. No tables or code blocks. |
blocker | Optional, for an incomplete round: stage (generation, grading or detection), code, message, and retryAfterSeconds when known. |
An incomplete round:
{"kind": "result", "roundId": "<round id>",
"result": {"runA": "<run A id>", "runB": "<run B id>",
"outcome": "incomplete", "decision": "finish", "verdict": "inconclusive",
"reason": "No winner yet: the detections did not finish.\n\n**What changed**\n- ...\n\n**What we saw**\n- ...\n- Decided on: quality, cost per case run\n\n**Next**\n- Queue the checks again after 00:00 UTC, then replace this result.",
"blocker": {"stage": "detection", "code": "PUBLIC_API_COMPUTE_BUDGET_EXCEEDED",
"message": "Daily detection limit reached; resets at 00:00 UTC", "retryAfterSeconds": 19500}}}A complete result can't be replaced. To replace an incomplete one, send a new result record for the same roundId after the missing grading or detections finish. Save each result before you start another round or finish.
Rules that save time
- Read the saved error before you change anything:
experiments get <id>, run attempts and check errors. - Limits don't clear on retry. Record a decision with the reset time.
- A refusal with every scope present means a missing role permission. Record a decision; don't sign in again.
- A missing detection result is not a pass.
- Run B once on one case outside the experiment before a round, to catch crashes cheaply.
- Set a budget before round 1. With no budget from the user: at most 3 rounds.
See Troubleshooting for each error.
