What one feedback record carries

L1ScreenConcept5 minScreenML breadth

RolesAgent Systems EngineeringDeveloper Experience and EducationCustomer AI Deployment

The question

You wrap every shell command that an agent runs so that the next turn can read what happened. What goes into the record, which field tells you whether the command worked, and what do you do when that field is empty?

Answer it first, aloud or on paper. Then open the answer.

The answer

Show short answer

The record carries the exact command as argv, the tail of stdout and the tail of stderr as separate fields, the exit code, the duration, the start time, and a one-line note of what the agent expected. The exit code is the success signal, because text can say anything and the code cannot. If the runner fails before it captures an exit, the record carries a null exit and an error reason, and the loop must not advance on it.

Show full answer

The fields

FieldWhy it is there
commandExact argv, so no shell expansion surprise
stdout_tailThe last lines of output, truncated the same way every time
stderr_tailThe last lines of errors, kept apart from stdout
exit_codeThe one unambiguous success signal
duration_msShows slow probes and runaway processes
started_atA timestamp for replay
agent_noteWhat the agent expected before it read the result

Truncation that does not lose the error

A large log destroys the loop. The runner keeps a fixed number of head lines and tail lines and inserts a marker that says how many lines it removed. The same output always gives the same record. Nothing is sampled, because the final error and the final summary live at the tail.

Redact at write

A record of stdout can carry a secret. The runner strips bearer tokens, password assignments, API keys and known key formats before it appends the line. Redaction at read time is a mistake, because the file on disk is what an attacker reaches.

Feedback is not telemetry

Telemetry is for operators reviewing runs across time. Feedback is for the next turn of this run. They share fields and live in different files with different retention.

Follow-ups

  1. L1ScreenWhy keep stderr separate from stdout?

    Show expected answer

    the failure summary often lands on one stream and progress on the other, and a merged tail can bury the summary.

  2. L2WorkingA command times out. What does the record say?

    Show expected answer

    a null exit code, an error field with the timeout, and whatever partial output was captured, and the loop refuses to advance.

  3. L2WorkingWhat is the agent note for?

    Show expected answer

    it records the prediction before the result, so a reviewer can see when the agent expected success and got a failure.

  4. L3SeniorA retry succeeds. How does the audit see the first failure?

    Show expected answer

    each record has a command id, and the retry carries the parent command id, so the chain is visible and the retry does not look like an independent success.

Wrong answers

Show the wrong answers that interviewers hear
  • “Parse the output for the word error to detect failure.”

    Output text varies by tool and language, and the exit code is the signal every command gives.

  • “Keep the whole output, because truncation can hide something.”

    A huge record pushes the loop out of its token budget, and the deterministic tail keeps the lines that matter.

  • “Redact when a human opens the log.”

    The file on disk is already the leak, so redaction has to happen before the append.

Taught in

The runtime feedback lesson builds the runner that writes this record.