Skip to content

Recipe Runner Logging Reference

Reference for live recipe progress, heartbeat events, bounded subprocess output snippets, run correlation pointers, and additive JSON fields emitted by amplihack recipe run.

A run logs its own progress. It does not trace, journal or attribute the Git commands its runner, steps, agents and hooks launch, on any platform. Steps work in the named checkout and its task or PR worktree, described in Recipe execution in named checkouts.

Contents

Output contract

amplihack recipe run keeps human-readable progress and machine-readable final results on separate streams.

Stream Contents Intended consumer
stderr Live recipe progress, step lifecycle lines, heartbeats, failure diagnostics, bounded snippets Humans, CI logs, terminal UIs
stdout Final command output in the requested --format (table, json, or yaml) Shell pipelines, scripts, jq

Default runs emit progress to stderr without requiring --verbose. --verbose increases detail; it is not required for basic progress.

amplihack recipe run default-workflow \
  -c task_description="Add cache headers" \
  -c repo_path=. \
  --format json > result.json

The terminal still shows live progress because progress is written to stderr, while result.json contains only the final JSON result from stdout.

Run identity and log pointers

Every run gets a stable UUID before the runner child starts. The wrapper exposes that UUID as AMPLIHACK_RECIPE_RUN_ID in the child environment and emits two correlation pointer lines to stderr.

Early pointer:

amplihack.recipe.log_pointer {"schema_version":1,"event":"early","run_id":"5b60657b-76ef-4f49-8a22-8b89ed75f43e","recipe_name":"default-workflow","cwd":"/home/user/src/myapp","worktree":"/home/user/src/myapp","run_dir":"/home/user/.amplihack/work/runs/5b60657b-76ef-4f49-8a22-8b89ed75f43e","branch":"main","task_description":"Add cache headers","runner_path":"/home/user/.local/bin/recipe-runner-rs","timestamp":"2026-06-12T03:55:11Z"}

Final pointer:

amplihack.recipe.log_pointer {"schema_version":1,"event":"final","run_id":"5b60657b-76ef-4f49-8a22-8b89ed75f43e","recipe_name":"default-workflow","status":"success","worktree":"/home/user/src/myapp","branch":"main","child_pid":41822,"exit_code":0,"runner_path":"/home/user/.local/bin/recipe-runner-rs","log_paths":{"jsonl":"/tmp/default-workflow.jsonl"},"timestamp":"2026-06-12T04:21:39Z"}

Pointer events include only explicit known metadata. Missing branch, issue, PR, child PID, and log path fields are omitted. The early pointer's run_dir is how amplihack recipe guide finds a run without the work-root environment. See Recipe Run Correlation Reference for the complete schema.

Live progress lines

Every step emits lifecycle progress in real time.

[recipe default-workflow] started (23 steps)
[step 04/23 requirements-clarification] started agent=prompt-writer
[step 04/23 requirements-clarification] heartbeat elapsed=60s status=running phase=agent
[step 04/23 requirements-clarification] completed elapsed=91s
[step 05/23 implementation-planning] started agent=architect
[step 05/23 implementation-planning] failed elapsed=34s error="agent exited with code 1"

Progress lines include:

Field Description
Recipe name The recipe being executed, such as default-workflow
Step index Current 1-based step number and total step count when known
Step id/name Stable step identifier from the recipe YAML
Phase recipe, agent, subprocess, bash, or finalize
Status started, running, completed, failed, or skipped
Elapsed time Wall-clock time since the step or recipe started
Child identity Agent name, subprocess command label, PID, or nested recipe name when available

Heartbeat events

Long-running recipe, agent, subprocess, and nested-recipe steps emit periodic heartbeats so callers can distinguish active work from a hung process.

Default heartbeat behavior:

Setting Default Description
First heartbeat After one interval Avoids noise for short steps
Interval 60 seconds Rate-limited per active step
Stream stderr Human-readable line plus structured log event
Contents Step id/name, phase, status, elapsed time, child identity when known Enough context to know what is still running

Heartbeat lines never include full child output. They may include a short progress hint such as the active agent name or subprocess label.

Recent output snippets

The runner keeps bounded rolling buffers for each active subprocess, agent, and nested recipe. Snippets are attributed by source and stream.

Attribute Behavior
Source agent:<name>, subprocess:<pid>, recipe:<name>, or step:<id>
Stream stdout, stderr, or combined
Bound Limited by line count and byte count
Retention Recent output only; older lines are dropped
Redaction No additional redaction guarantee; snippets are bounded but may contain whatever the child printed
Live output Snippets are summarized in progress logs; noisy child output is not streamed unbounded

Do not print secrets from recipe steps. The transparency feature limits snippet size and attribution, but it is not a substitute for secret-safe child tools.

Snippets appear in:

  • step failure diagnostics printed to stderr
  • JSON result fields when --format json is used
  • JSONL recipe log events when recipe logging is enabled

Failure context

Failures include actionable context instead of only a generic step failure.

[step 08/23 code-implementation] failed elapsed=12m14s agent=builder
error: agent exited with code 1

recent stderr from agent:builder (last 20 lines, 8192 bytes max):
  error[E0425]: cannot find value `cache_policy` in this scope
  --> src/http/cache.rs:42:18
   |
42 |     apply_policy(cache_policy);
   |                  ^^^^^^^^^^^^ not found in this scope

recent stdout from agent:builder:
  Running cargo test --quiet

Failure diagnostics include these fields when known:

Field Description
step_id Stable recipe step id
step_name Human-readable step name or label
phase Current phase at failure time
status failed
elapsed_seconds Step duration
child Agent, subprocess, or nested recipe identity
exit_code Child process exit code when applicable
recent_output Bounded attributed stdout/stderr snippets

JSON result fields

The final JSON result remains backward-compatible. Existing fields are preserved; new fields are optional and additive.

Top-level result:

Field Type Required Description
recipe_name string yes Recipe name
success boolean yes, when used by the existing result schema Boolean overall result
status string yes, when used by the existing result schema Overall result such as SUCCESS, FAILURE, or PARTIAL
step_results array yes Ordered step results
context object no Final context values
duration_seconds number no Total recipe duration
progress_summary object no Last known phase/status, heartbeat count, and log path
failure_context object no Failure context for the first failing step
run_id string no Stable UUID for this recipe invocation
log_pointer object no Concise final pointer summary with status, child PID, runner path, worktree, branch, and log paths

Step result additive fields:

Field Type Required Description
step_id string yes Stable step id
status string yes completed, failed, or skipped
output string no Step output or summary
error string no Error message
step_name string no Human-readable name
phase string no Last phase for the step
elapsed_seconds number no Step duration
started_at string no RFC 3339 timestamp
completed_at string no RFC 3339 timestamp
child object no Agent, subprocess, or nested recipe identity
last_heartbeat_at string no RFC 3339 timestamp of last heartbeat
recent_output array no Bounded attributed snippets

child object:

{
  "kind": "agent",
  "name": "builder",
  "pid": 12345,
  "command": "copilot --agent builder"
}

recent_output entry:

{
  "source": "agent:builder",
  "stream": "stderr",
  "line_count": 20,
  "byte_count": 4096,
  "truncated": true,
  "text": "error[E0425]: cannot find value `cache_policy` in this scope\n..."
}

Consumers should ignore unknown fields and treat every field in this section as optional unless listed as required in the existing schema. The amplihack CLI must preserve additive fields emitted by recipe-runner-rs when it formats --format json or --format yaml; parsing the runner JSON and then dropping unknown diagnostic fields is a bug.

JSONL log events

When recipe logging is enabled, the log file contains JSONL events with enough context to reconstruct progress.

The runner reads AMPLIHACK_RECIPE_RUN_ID from its environment and writes that same value to event run_id fields. The amplihack recipe run wrapper supplies the environment value but does not rewrite JSONL files after the child exits.

Lifecycle event:

{
  "type": "step_lifecycle",
  "run_id": "5b60657b-76ef-4f49-8a22-8b89ed75f43e",
  "recipe_name": "default-workflow",
  "step_index": 8,
  "total_steps": 23,
  "step_id": "code-implementation",
  "step_name": "Code implementation",
  "phase": "agent",
  "status": "started",
  "child": { "kind": "agent", "name": "builder" },
  "elapsed_seconds": 0.0,
  "timestamp": "2026-06-03T18:12:00Z"
}

Heartbeat event:

{
  "type": "heartbeat",
  "run_id": "5b60657b-76ef-4f49-8a22-8b89ed75f43e",
  "recipe_name": "default-workflow",
  "step_id": "code-implementation",
  "step_name": "Code implementation",
  "phase": "agent",
  "status": "running",
  "child": { "kind": "agent", "name": "builder" },
  "elapsed_seconds": 180.0,
  "timestamp": "2026-06-03T18:15:00Z"
}

Output snippet event:

{
  "type": "output_snippet",
  "run_id": "5b60657b-76ef-4f49-8a22-8b89ed75f43e",
  "recipe_name": "default-workflow",
  "step_id": "code-implementation",
  "source": "agent:builder",
  "stream": "stderr",
  "recent_output": {
    "line_count": 12,
    "byte_count": 2048,
    "truncated": false,
    "text": "Running cargo test --quiet\n..."
  },
  "timestamp": "2026-06-03T18:15:30Z"
}

Git commands a run makes

A run keeps no record of the Git commands its runner, steps, agents and hooks launch. Nothing traces, journals or attributes them, on Linux or anywhere else. There is no git-commands.jsonl, no git-trace2/ directory, no git-recording.json and no diagnostics/git/ directory in a run folder, and run.json carries no git_recording field.

Steps run in the caller-selected checkout or the workflow's legitimate task or PR worktree. A separate read-only pre-review baseline supports agentic assessment of reviewer changes; it is not a Git-command journal. See execution and review evidence.

Caller Git trace variables are cleared

A run clears GIT_TRACE2, GIT_TRACE2_EVENT, GIT_TRACE2_PERF, GIT_TRACE2_CONFIG_PARAMS, GIT_TRACE2_REDACT and GIT_TRACE2_ENV_VARS from the runner's environment, and sets none of them itself. Exporting one before amplihack recipe run therefore does not trace the run's Git commands; it has no effect on them at all.

This is deliberate, and it is a credential boundary rather than a tidiness rule. Git redacts Authorization: headers in its Trace2 output by default, and GIT_TRACE2_REDACT=0 turns that redaction off. An environment carrying both a GIT_TRACE2* target and GIT_TRACE2_REDACT=0 would otherwise write the auth headers of the run's Git traffic to a target chosen outside the run. Full command lines can carry secrets the same way, so the whole namespace is cleared rather than filtered.

The clearing is of the environment only. A run reads the user's own global and system Git configuration, so a trace2.normalTarget, trace2.eventTarget or trace2.perfTarget set in ~/.gitconfig does take effect inside a run and writes to the target it names, and trace2.configParams and trace2.envVars widen what is written there. That is the user's own setting rather than an inherited one, and the boundary this section is about survives it: redaction has no configuration equivalent, so GIT_TRACE2_REDACT being cleared leaves Git's default redaction of Authorization: headers in force whichever way the target was chosen. See paths and Git configuration.

To trace Git inside a run, set the variable where the Git command actually runs — in the recipe step itself — so the target is one you chose for that step and the trace does not follow every other process in the run:

- id: trace-one-step
  type: bash
  command: |
    mkdir -p "$PWD/trace2"
    GIT_TRACE2_EVENT="$PWD/trace2" git fetch --prune

The target can be a file or a directory, and Git treats them differently: a path that names an existing directory gets one trace file per Git process, while any other path is appended to as a single file. Create the directory first, as above, if you want the per-process form.

Trace2 output written this way is Git's, not amplihack's. Nothing reads it back and it has no effect on the run's outcome, but it can hold full command lines, so give it a target only you can read.

Run directories from earlier releases

A run folder written before this release can still hold git-commands.jsonl, git-trace2/, git-recording.json or diagnostics/, and its run.json can still carry a git_recording object. Nothing writes or reads them now, and a run.json that carries the field still parses.

Nothing removes them either. They sit at the top level of the run folder, outside the disposable runtime/ directory the runner deletes when a run ends, and they belong to none of the categories the cleanup sweep collects (run-tmp, run-worktree, run-target). Run folders themselves are never pruned, so an old recording stays until you delete its folder yourself. git-commands.jsonl recorded the full command line of every Git process the run started, which can carry credentials, so treat an old run folder as readable only by you. See Clean up after recipe runs.

Configuration

Defaults are conservative and bounded. Configure them through environment variables or the matching keys in ~/.amplihack/config.

Environment variable Config key Default Description
AMPLIHACK_RECIPE_HEARTBEAT_INTERVAL_SECONDS recipe.heartbeat_interval_seconds 60 Seconds between heartbeat lines per active step. Set 0 to disable heartbeats.
AMPLIHACK_RECIPE_SNIPPET_LINES recipe.snippet_lines 20 Maximum recent lines retained per source/stream.
AMPLIHACK_RECIPE_SNIPPET_BYTES recipe.snippet_bytes 8192 Maximum bytes retained per source/stream.
AMPLIHACK_RECIPE_LOG_JSONL recipe.log_jsonl unset Optional path for structured JSONL recipe events.
AMPLIHACK_RECIPE_RUN_ID none generated Stable run UUID injected by the wrapper into the child environment and copied by the runner into JSONL event run_id fields. Treat as read-only.

Environment variables take precedence over config-file keys.

Use --verbose to include child launch details and additional snippet context:

amplihack recipe run default-workflow \
  -c task_description="Update dependencies" \
  --verbose

--progress is not a supported amplihack recipe run flag. Passing it fails with an actionable message explaining that progress is already emitted to stderr by default and that --verbose only increases diagnostic detail.

Examples

Capture final JSON while watching progress:

amplihack recipe run default-workflow \
  -c task_description="Add input validation" \
  -c repo_path=. \
  --format json > /tmp/recipe-result.json

Extract pointer events from a captured progress log:

grep '^amplihack\.recipe\.log_pointer ' /tmp/progress.log \
  | sed 's/^amplihack\.recipe\.log_pointer //' \
  | jq '{event, run_id, status, child_pid, exit_code, log_paths}'

Write a JSONL event log:

AMPLIHACK_RECIPE_LOG_JSONL=/tmp/default-workflow.jsonl \
amplihack recipe run default-workflow \
  -c task_description="Fix flaky retry tests" \
  -c repo_path=.

Show the failing step and recent stderr from the final JSON:

jq '.step_results[]
  | select(.status == "failed")
  | {step_id, elapsed_seconds, child, recent_output}' /tmp/recipe-result.json