How Much of an Agent's Behavior Should a Developer Understand?
An agent's code change differs from expectations. Its completion report says tests were checked, but does not clarify what happened. Before rewriting the prompt, ask:
What information was supplied, which commands ran, and what did their results establish?
You need not study the entire model architecture first. Distinguishing requests, tool execution, and returned results can narrow the next investigation. Consider a small list-sorting example.
Files and code are educational examples. File reads and Python test outputs were checked in a temporary directory with Python 3.14.5 during revision on 2026-10-24. They are not service logs or the user's past experiences. Logs are excerpted, omitting temporary paths and repetitive output. Permission and database scenarios are separately identified as hypothetical.
1. Tools and an environment sit between request and execution
User request and current context→ model responds or chooses a tool→ execution system applies tool, permission, and environment conditions→ tool returns output or an error→ model uses the result to choose its next actionThe surrounding system managing context, tool calls, state, and execution boundaries is often called a harness. OpenAI describes the Codex harness as managing conversation state, tool use, sandboxing, and approval policies. Codex as a platform
This distinction prevents conflating requested work with performed work. “Test it” is a request; “I will test it” is an explanation; a command and its returned output support what was attempted and observed. Ask which command ran, where, and what it printed.
2. Finding a file differs from receiving its contents
The example contract is descending creation time, ascending ID for ties, and page size 2, stored in docs/list-contract.txt.
A path lookup returned:
docs/list-contract.txtThat establishes that the path appeared, not that its contents were returned. Reading it later produced:
sort: created_at DESC, id ASCpage_size: 2Now there is evidence the tool returned the contract. Receiving the contents still differs from correctly applying them.
| Observation | Established | Still unverified |
|---|---|---|
| Path listed | File located | Body read |
| Body returned | Contents supplied | Applicability to this task |
| Diff matches contract | Inspected code expresses it | Actual execution path follows it |
Conversely, absence of a visible read command does not prove absence of the content. It may have arrived in user input, automatically loaded instructions, or an incompletely displayed history. AGENTS.md has its own discovery/application rules; distinguish automatic instructions from ordinary file reads. AGENTS.md documentation
State the sorting contract used for this change and its supporting file.Separate confirmed content from assumptions and connect each conditionto the implementing part of the current diff.A filename in the answer is not sufficient; compare the contents with the actual diff.
3. A command ending does not mean a test ran
Running a nonexistent file:
python3 missing_test.pyproduced:
can't open file '…/missing_test.py':[Errno 2] No such file or directoryExit code: 2Python started but could not open the file. It never reached the list-function test. This does not establish a pagination defect; inspect working directory, path, and test entry point first.
| Observed situation | First investigation |
|---|---|
| Test file missing | Directory and path |
| Package import failure | Environment and dependencies |
| Database connection fails during setup | Target, settings, database readiness |
| Expected/actual assertion fails | Requirements, input, implementation |
The database row is hypothetical, not executed here. A connection failure could reflect settings, server state, or a code change and needs investigation. A completion report may call all these “test failure”; identify where execution stopped before choosing a fix.
4. What does an assertion failure add?
Next, an actual test module ran:
python3 -B -m unittest -v test_paginationIts input puts tied items in reverse ID order:
ID 11: 10:00ID 13: 09:00ID 12: 09:00ID 14: 08:00ID 15: 07:00The contract requires first page [11, 12]:
self.assertEqual([11, 12], page_ids(ROWS, 1))The run returned:
test_first_page_tie_break ... FAILAssertionError: Lists differ: [11, 12] != [11, 13]Ran 1 test in 0.000sFAILED (failures=1)Exit code: 1Unlike the path failure, this reached the comparison. Inspect whether the expected IDs match the contract, the input actually includes ties, the key contains ID, and the page slice is correct.
The example was missing the tie-break:
key=lambda row: -row["created_at"]It was changed to:
key=lambda row: (-row["created_at"], row["id"])The same test then produced:
test_first_page_tie_break ... okRan 1 test in 0.000sOKExit code: 0The precise finding is one first-page tie-order test failed before the change and passed afterward on this input. It does not validate all pagination, a real API, or database integration. See judging code you did not write for contract/test review.
5. Do not judge success from exit code alone
| Execution | Exit code | Meaning with its output |
|---|---|---|
| Missing file | 2 | Could not open the requested file |
| Before-fix test | 1 | Test ran; one assertion failed |
| After-fix test | 0 | The one executed test passed |
These numbers do not mean the same failure cause in every tool. A custom comparison script can catch assertions, print FAIL, and exit 0. Discovery paths or filters can omit intended tests, so check targets and counts too.
Codex App Server documentation separates command, working directory, status, output, and exit code in execution records. Interfaces display these differently, but the evidence can be inspected at that level. App Server documentation
Report command and working directory, test target/count,exit code and key output, and checks not run or still unresolved.Distinguish normal process exit from requirement verification.6. Treat permission-blocked execution separately
No permission block was reproduced here. A request denied before execution is not a test result. A command that starts and later fails on file permissions requires inspecting how far it got and any remaining changes.
Sandboxing defines technical file/network access boundaries; approval policy governs actions requiring approval. Permissions and execution boundaries
Identify the blocked action, whether denial happened before or during execution, whether access is necessary for the task, and whether an allowed alternative exists. Stronger prompt wording alone does not change execution conditions.
7. Choose depth by the next decision you need to make
| Unanswered question | Topic to investigate |
|---|---|
| Which evidence guided the change? | Supplied context, instructions, file results |
| Why did tests not start? | Directory, dependencies, environment |
| Why was access blocked? | Permissions and approval policy |
| Why do expected and actual values differ? | Contract, input, implementation, test |
| Why do context/tool problems recur? | Workflow, context management, harness configuration |
This is a way to choose relevant study, not a mandatory curriculum. Logs expose observable behavior and results, not the model's complete internal reasoning. Reading a file and then changing code incorrectly does not reveal a single certain internal cause; investigate failed application and differing interpretation separately.
For one task, record:
Evidence inspected:Commands run and results:Still unverified:One next check:For this example:
Evidence: The sorting-contract body was returned by a tool.Execution: First-page tie-order test failed before and passed after correction.Unverified: Other pages and actual API/database paths.Next check: Does the real change include those API/database paths?The next article connects these observations to decisions before delegation: what should developers decide when more work can be delegated?
Report an error or share feedback
Open a draft with this article’s title and URL. Review the message and recipient before sending.
Open email draftIf no email app opens, copy these details into your usual email service.
Related posts
AI Using AI Coding Agents Well: Design the Delegation Before Comparing Tools
Turn a hypothetical session-expiration notice into a specification, acceptance criteria, and verification evidence before comparing coding agents.
Today I Learned 2026-10-06 Practical Claude Code Commands for Developers
A situation-based guide to Claude Code planning, context, recovery, diff, and review commands, checked against official documentation on October 24, 2026.