Phase 14: Agent Engineering

Runtime Feedback Loops

Agents that do not see real command output guess. A feedback runner captures stdout, stderr, exit code, and timing into a structured record the next turn can read. Then the agent reacts to facts instead of to its own prediction of facts. Distinguish runtime feedback from observability telemetry. Build a feedback runner that wraps shell commands and persists structured records. Truncate large outputs deterministically so the loop stays within token budget. Refuse to advance the loop when feedback is missing. The agent says "running tests now." The next message says "all tests pass." The reality is that no test ran. The agent imagined the output, or it ran the command and never read the result, or it read the result and silently truncated the failure line. A feedback runner removes that gap. Every command goes through the runner. Every record carries the command, the captured stdout and stderr, the exit code, the wall-clock duration, and a one-line agent note. The agent reads the record at the next turn. The verification gate reads the records at the end of the task. A 50 MB log destroys the loop. The runner truncates head and tail with a ...truncated N lines... marker, deterministic so the same output always produces the same record. No sampling; the parts the agent needs to see (final error,…

Runtime Feedback Loops: Agents that do not see real command output guess. A feedback runner captures stdout, stderr, exit code, and timing into a structured…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.