Building a Coding Agent from Scratch, Part 4: Autonomy Rules Are for When Nobody Is Around. If a Human Is Present, Stop and Ask

The "don't stop" discipline honed in evaluation runs was firing even when a human could answer: building unasked after a question, re-asking a declined confirmation seven times. From 19 defects found by role-playing six kinds of usage, we describe the design for when a human is present.

Building a Coding Agent from Scratch, Part 4: Autonomy Rules Are for When Nobody Is Around. If a Human Is Present, Stop and Ask

Hello!

Around the time our own coding agent had started completing evaluation tasks reliably, we tried using it "as a person" for the first time. We opened the chat screen in an empty directory and typed:

"Make something."

The model's first response was, "What are you looking for? What kind of thing would you like to build?" That is correct. A vague instruction should be met with a question.

But the harness judged that as "did nothing," pushed it back, and the model went ahead and built a Python web app on its own and reported "Done." I had not answered anything.

To put the conclusion first, the "don't stop" discipline we had honed in unattended evaluation runs was entirely for situations where nobody is around to answer. If a person is in front of the screen and can answer, the right thing is to stop and ask. Applying the discipline honed in evaluation runs unchanged to interactive situations surfaced as 19 defects in a test where we role-played six kinds of usage.

This article is Part 4 of the series "Building a Coding Agent from Scratch." This time we describe the flip side of "don't stop": the design for situations where a human is present.

PartTheme
Part 1Why "finishing the job" is hard. Separating the turn runner from the stop decider
Part 2"Done" means "it runs," not "it's written." The completion gate and how to write a pushback
Part 3"It didn't stop" is not "it made progress." Count idle turns, and cap them without cutting the thinking
Part 4 (this post)Autonomy rules are for when nobody is around. If a human is present, stop and ask
Part 5Making local LLMs first-class citizens. Getting two 16GB GPUs to build a web system
Part 6How to build the evaluation. Have it build something that runs, auto-grade it, and doubt the grader itself
Part 7Logging and regression. Everything is found in the event log. And building with zero dependencies

1. Defects That Evaluation Runs Can't Find Won't Be Found by Evaluation Runs

Why had not a single one of these defects appeared in the more than 100 evaluation runs up to then?

An evaluation run hands over a specification, runs unattended, and grades the deliverable. It never gives a vague instruction, nobody declines a confirmation, and it never creates a situation where someone else's process is holding a port. Defects that appear in evaluation runs only appear in the form of evaluation runs.

We are a one-person development team, so we cannot have other people try it. So the developer took on other personas and used it. Six of them.

PersonaWhat they do
The first-timer"Make something" in an empty directory. Hits Enter three times in a row. "Thanks"
The impatient oneQueues two instructions while it's running. Stops it midway with Esc. "Continue"
The maintainer"Fix the failing test. Don't commit"
The cautious oneDeclines every execution confirmation with n. Switches to read-only and then asks for a write
The web UI userOpens two browser tabs. Closes one. Queues, cancels, stops, answers a question
The misconfigurerStarts on a machine with no API key. Mistypes the model name. Points at a nonexistent working directory

We prepared a 1-to-5-minute script per persona and played them in order, and each surfaced 2 to 5 different holes. The rest of this article is what they were.

2. The Same Situation Has a Different Right Answer Depending on Whether a Human Is Present

Figure 1: The same situation, a different right answer depending on whether a human is present (diagram: Qualiteg)
Figure 1: The same situation, a different right answer depending on whether a human is present (diagram: Qualiteg)

2-1. If a human is present, a question stops and waits

This is the "make something" case from the opening.

The pseudocode shown in Part 1 is the form after we fixed it through this persona test. Even before the fix, "when the user's answer is needed" was one of the reasons it may stop. But that judgment only fired when the model explicitly called the question tool, and a response that merely asked a question in its body was classified as "did nothing". In an unattended evaluation run that is correct, because it is a situation where we should push back with "don't ask; assume and proceed."

On the chat screen it is different. If someone can answer, a question on the first turn simply stops and waits for the answer. If nobody is present, push back with "assume and proceed" attached. We made the judgment on the same response split according to whether a human is present.

2-2. A declined confirmation is not asked again until the next instruction

The "cautious one" script produced the most defects.

With execution confirmation enabled, ask it to "run the tests" and answer n to the confirmation. After the refusal, the harness's advice was "ask the user with the question tool, then retry." The model then asked a nonsensical question: "Do I need to use the standard profile?"

We changed the advice to "if declined, don't ask again. Proceed without it, or report and stop" and reran. This time the model tried four times in different forms. npm test was declined, so it tried node --test, and when that was declined, cd tests && node --test. Each time a confirmation appeared, and the user had to stop it every time.

Worse, at that moment the harness was pushing back with "don't repeat the same failure; fix the cause." It was counting the declined confirmation as a "failure to be fixed." The model took that and went looking for a way around. The harness was egging on the search for a workaround.

We fixed three things. Failures caused by the user's policy (declined confirmations, denied permissions) are not counted in the continuation judgment. A confirmation of the declined kind (the kind of permission, such as execute or write) is not asked again until the user gives the next instruction, and is automatically failed. And in that profile, automated verification does not run tests on its own either.

The last one was actually a defect where, right after the user declined n, the harness's automated verification ran the very same npm test on its own. We were conveying the user's intent to the model while not honoring it ourselves. Unless execution permission is "allowed," automated verification is now limited to a syntax check.

In the fourth rerun, the confirmation appeared exactly once, the subsequent five attempts failed automatically, and the user was not asked.

2-3. For "don't ask again," a key of "the same turn" was not enough

A small detail, but here is one number we measured.

We first implemented "don't re-ask a declined kind of confirmation" as "within the same turn." Large models call multiple tools per turn, so we thought that would suffice. But a small model that calls only one tool per turn asked again seven times across different turns and ran straight to the 40-turn limit.

Changing the key to "until the user's next instruction" settled it. A hole we only saw because we checked with a small model.

3. Don't Let the Model Decide "Who Started This Process"

The "impatient one" script produced a different kind of defect.

The model tried to start a server on port 3000, and the port was in use (EADDRINUSE). That port was held by a different app unrelated to this run. The harness's advice was:

"If it's a process started by this run, kill it. To kill it: taskkill /PID <number>"

It delegated the judgment to the model, and even showed how to kill it. This time the model killed only the process it had started itself, so no harm was done, but it could very well have killed someone else's app.

Figure 2: The machine knows who started a process (diagram: Qualiteg)
Figure 2: The machine knows who started a process (diagram: Qualiteg)

What we realized here is that the harness knows "who started it". It remembers the PIDs of the processes it started itself. So the judgment need not be left to the model; it can be separated mechanically.

Processes started by this run may be killed. Processes started by others go to the user for confirmation (or, unattended, fail and suggest a different port). The harness's own processes are refused. And forms that kill by name in bulk (taskkill /IM node.exe, pkill node) are refused by the form itself, without looking at the arguments.

The last one has a backstory. In an evaluation run, the model executed Get-Process -Name node | Stop-Process, and the harness itself was killed and the run vanished. Looking only at "the arguments of the kill command" cannot stop a form that collects via a pipeline and then kills. We had to look at the whole form of "collect by name, then kill."

Cleanup was fixed along the same lines. When a session ends, stop the servers the model started and left behind. At one point three servers were left on the machine, a defect invisible in evaluation runs because the evaluation rig had been stopping them. Furthermore, chains like npm run web & (cmd -> node -> cmd -> node) leave parts behind on a busy machine because enumeration of descendants cannot keep up, so we also kill "anything born in the meantime that has lost its parent" as a batch.

4. If Something Was Started in the Background, Say So

Running the same scripts with a large model, the skeleton of the dialogue (queue, interrupt, resume, refuse, clean up, log) held. Instead, one different friction appeared.

When the model starts a server in the background with node server.js &, the shell exits immediately. All the model gets back is "exit code: 0" and empty output. It cannot tell whether it worked. The model tried the same startup five ways (&, two forms of start /b, with a redirect to a log, and PowerShell's Start-Process), two of which hit the 120-second timeout, concluded "& does not work in this shell," and burned about four minutes.

The harness had adopted the background child process and remembered its PID. It knew, but it kept quiet toward the model. When the command is written in a way that clearly backgrounds a process, we now attach to the result: "Started in the background (pid n). Don't repeat the same startup. Verify with a different command, and stop it when done."

This was a form hard to see in evaluation runs. There, the main path was starting in the foreground and detecting the listener; it only showed up in numbers when a person asked "write tests too" and had the model start the server itself.

5. Configuration Problems: One Line and the Next Step, Not a Stack Trace

The "misconfigurer" script is the plainest, and the very first place a user steps.

Starting on a machine with no API key. Mistyping the model name and getting a 404. The endpoint being down and unreachable. Pointing at a nonexistent working directory.

The first version stopped with a stack trace in every case. Worse, 404 and 401 were treated the same as "temporary failures" and resent five times, after which the circuit breaker tripped and it stopped. From the user's point of view, they waited tens of seconds without knowing what was wrong.

Figure 3: Stop configuration problems with one line and the next step (diagram: Qualiteg)
Figure 3: Stop configuration problems with one line and the next step (diagram: Qualiteg)

A 401 or 403 for a missing key, a 404 for a wrong model name, and a 400 for a bad setting will not pass no matter how often you resend. Stop within one turn and report the reason in one line plus the next step (the command to check the setting). The context-overflow 400 from Part 3 is different: that one is compacted and resent. If the endpoint is merely down temporarily, retry up to the limit as in Part 1, then stop. We also gave it a distinct exit code as "a failure the user fixes."

One more thing: operations that only read the record (listing or aggregating past sessions) were demanding the model connection settings, because a read-only operation was assembling the entire agent. If it only reads, assemble only the record component. Even a small decomposition like this changes whether you can read the record on a machine without a key.

6. Six Personas, 19 Defects

The persona tests found and fixed 19 defects. Laid out in a table, most of them fall under "applying evaluation-run discipline unchanged to interactive use."

PersonaCountDefects found (summary)
The first-timer2Pushes back a question and builds on its own. Brings up the previous run's verification results in reply to "thanks." Replies in a different language (model)
The impatient one4Queued instruction is displayed twice. Shows how to kill someone else's process. Background startup returns only "exit 0." Doesn't stop leftover servers on exit
The maintainer2Creates a summary file nobody asked for. Working directory shows up in git status
The cautious one4Asks again after being declined. Asks again seven times in different forms. Counts refusals as failures and pushes back. Automated verification runs tests on its own
The web UI user2Not a single session is saved. Fails 12 times when the TODO argument shape differs
The misconfigurer5Stack traces. Demands a key just to read the record. Resends a 404 five times

Today, this agent stops and asks on vague instructions. Instructions given mid-run are queued and picked up on the next turn. Esc stops it even mid-thought, and the next instruction resumes from there. A declined confirmation is not asked again. Other people's processes are not killed. Configuration problems stop with one line. Leftover servers are stopped on exit.

None of this adds a single point to the evaluation score.

Summary: "Don't Stop" and "Stop and Ask" Are Decided by the Same Role

SituationNobody present (unattended run)Human present (chat screen)
The model asked a questionPush back with an assumption attachedStop and ask
A confirmation was declinedLook for a move that needs no confirmationDon't re-ask the same kind of confirmation until the next instruction
Someone else's process holds the portFail and suggest a different portSend to the user for confirmation
Execution permission requires confirmation(Unattended, grant it explicitly)Automated verification is syntax check only
Configuration problemStop with one line and the next stepSame

The "stop decider" described in Part 1 was never a role just for "not stopping." It takes whether a human is present as an input and returns the opposite judgment for the same situation.

Next time: the local LLMs that underpin every experiment in this series. How we handled model quirks, quantization degradation, GPU memory, and repairing broken tool calls on the way to getting two 16GB cards to build an entire web system. With tables of measured numbers.

See you next time!

Read more

Understanding Active Directory: The Technology Behind Enterprise AI Security - Part 7: Security and Best Practices

Understanding Active Directory: The Technology Behind Enterprise AI Security - Part 7: Security and Best Practices

Hello! In this seventh installment of the series, we cover Security and Best Practices - considerations for production environments. Series overview * Chapter 1: Understanding the basics - Fundamentals of Active Directory and Kerberos/NTLM authentication * Chapter 2: Building a domain environment - Setting up a lab environment * Chapter 3: Joining

By Qualiteg Consulting