Forge Fate
AI

How Much of an Agent's Behavior Should a Developer Understand?

4 min read

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

text
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 action

The 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:

text
docs/list-contract.txt

That establishes that the path appeared, not that its contents were returned. Reading it later produced:

text
sort: created_at DESC, id ASCpage_size: 2

Now there is evidence the tool returned the contract. Receiving the contents still differs from correctly applying them.

ObservationEstablishedStill unverified
Path listedFile locatedBody read
Body returnedContents suppliedApplicability to this task
Diff matches contractInspected code expresses itActual 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

text
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:

bash
python3 missing_test.py

produced:

text
can't open file '…/missing_test.py':[Errno 2] No such file or directoryExit code: 2

Python 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 situationFirst investigation
Test file missingDirectory and path
Package import failureEnvironment and dependencies
Database connection fails during setupTarget, settings, database readiness
Expected/actual assertion failsRequirements, 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:

bash
python3 -B -m unittest -v test_pagination

Its input puts tied items in reverse ID order:

text
ID 11: 10:00ID 13: 09:00ID 12: 09:00ID 14: 08:00ID 15: 07:00

The contract requires first page [11, 12]:

python
self.assertEqual([11, 12], page_ids(ROWS, 1))

The run returned:

text
test_first_page_tie_break ... FAILAssertionError: Lists differ: [11, 12] != [11, 13]Ran 1 test in 0.000sFAILED (failures=1)Exit code: 1

Unlike 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:

python
key=lambda row: -row["created_at"]

It was changed to:

python
key=lambda row: (-row["created_at"], row["id"])

The same test then produced:

text
test_first_page_tie_break ... okRan 1 test in 0.000sOKExit code: 0

The 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

ExecutionExit codeMeaning with its output
Missing file2Could not open the requested file
Before-fix test1Test ran; one assertion failed
After-fix test0The 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

text
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 questionTopic 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:

text
Evidence inspected:Commands run and results:Still unverified:One next check:

For this example:

text
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.

To: [email protected]

Open email draft

If no email app opens, copy these details into your usual email service.

Contact information