a-handoff-is-not-a-sta…
AgentAt the end of each session your agent writes a paragraph that says what it did. The next session still spends its first half hour…
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?
Claude Code
$ npx -y skills add rohitg00/ai-engineering-from-scratch --agent claude-code
Cursor
Cursor also loads subagents from .claude/agents, so copy this file there to use it in Cursor.
id: what-a-feedback-record-carries title: What one feedback record carries card: agents kind: concept level: 1 roles: [agentic-ai-engineer, ai-developer-relations-engineer, forward-deployed-ai-engineer] rounds: [screen, ml-breadth] tags: [feedback-record, exit-code, truncation, redaction, telemetry] minutes: 5 lessons: [phases/14-agent-engineering/37-runtime-feedback-loops] manuals: [] practice: [] cheatsheet: [agent-workbench-ops] related: [agents/tests-passed-but-nothing-ran] updated: 2026-11-03
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?
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.
| Field | Why it is there | |---|---| | `command` | Exact argv, so no shell expansion surprise | | `stdout_tail` | The last lines of output, truncated the same way every time | | `stderr_tail` | The last lines of errors, kept apart from stdout | | `exit_code` | The one unambiguous success signal | | `duration_ms` | Shows slow probes and runaway processes | | `started_at` | A timestamp for replay | | `agent_note` | What the agent expected before it read the result |
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.
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.
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.
The [runtime feedback lesson](../../../phases/14-agent-engineering/37-runtime-feedback-loops/) builds the runner that writes this record.
At the end of each session your agent writes a paragraph that says what it did. The next session still spends its first half hour…
Read this part of the harness loop. A subscriber on `before_tool_call` raises `HookAbort` on the second step of a three-step…
The task given to the agent was to fix one login bug. The diff changes the login route, an email helper, the database driver, the…
The product team wants a single maximum number of turns that applies to every run of your agent. The agent handles one-line…
Read this run method from the toy agent loop. A caller shows the returned string to the user as the answer. What is wrong with…
A long coding session has used most of its context window. The runtime offers to summarize the older turns and keep going. Your…
Reviews the repository's shared Claude Code configuration (.claude/settings.json, CLAUDE.md, .claude/rules/, .mcp.json and the…
Generate comprehensive API documentation by scanning Express route files.
Advisor to a busy principal. Optimizes for the user's time, attention, and decision quality. One of the starter-kit council…