I specified a required step and then specified what to do when it's skipped
I made a mistake in a design document, and because our design documents are authoritative over the code, it became a mistake in every implementation that followed them. I want to write down what I did, why it was wrong, and what I should have written instead, mostly so I recognise the shape next time.
What I wrote
Our system dispatches agent sessions to work on issues. When a session ends, the system needs to know how it ended: did the work get done, is the issue still open and why, or did it fail. That one value drives a lot. It decides whether the session’s branch gets merged, whether the attempt counts as a strike against the issue, whether the issue gets put on hold after repeated strikes, and whether an alert is raised when the reported outcome disagrees with the state of the work.
I specified that the session reports this value by calling a tool on our issues server “as its last act”. The prompt templates tell the session to do its work, commit, close the issue, and then make one more tool call to say how it went. I wrote numbered requirements for the tool’s arguments, for which callers it is visible to, for what it refuses, and for how a later call replaces an earlier one. I also wrote the recovery: a session that ends without reporting gets handed a second prompt asking it to report, and if it still doesn’t, it is assigned a synthetic outcome of “failed, unreported”.
All of that is internally consistent. All of it is wrong.
Why it’s wrong
The requirement enforces nothing
“As its last act” is a sentence. Nothing makes it true. The agent is a language model at the end of a long session. It has committed, closed the issue, and been told to end its turn. The one remaining step is a bookkeeping call whose only beneficiary is the system itself. That is precisely the step most likely to be dropped, and I knew it, because I wrote a recovery path for it in the same document. Specifying what to do when a required step is skipped is an admission that it isn’t actually required.
I already had the right mechanism, and I’d already used it
Three days after writing the outcome requirements, I wrote the requirements for a different kind of session, a one-off task. For those, I specified that the harness is started with a structured-output schema, and that the session’s final result is the report. The harness refuses a final result that doesn’t match the schema. A task session cannot end without a well-formed report; there is no “skipped” case to recover from.
I did not go back and revisit the issue outcome. Same design, same author, same week. The task requirements give a guarantee; the issue requirements give a request and a fallback.
The analogy I keep coming back to: a function that returns a value versus a void function whose contract says it will write its result through an out-parameter. The return value is part of the signature; you can’t call the function without getting one, and the type is checked. The out-parameter is a promise every code path has to remember to keep, and nothing checks that it did. I had the return value available and chose the out-parameter.
The design grew to compensate
Because the report can be missing, late, duplicated, or contradicted by the work, I wrote requirements for each of those cases:
- a second prompt for a session that finished without reporting, plus a rule for sessions that finished while the supervising agent was down;
- a synthetic “unreported” outcome, which then needed its own place in the strike rules and the merge rules;
- a rule that later issue operations clear an earlier report, because the session can call tools in any order;
- a rule that a later report replaces an earlier one, for the same reason;
- a cross-check of every report against the issue’s actual state, with a list of refusals;
- visibility rules so only dispatched sessions see the tool.
With structured output, the report is made exactly once, at the end, after every other act, and it cannot disagree with “the last thing the session did” because it is the last thing the session did. Most of that list simply disappears. When a design needs this much machinery around one value, the design is telling you the value is being obtained the wrong way. I didn’t listen.
I put it in the wrong component
The issues server’s job is issue files: file, update, close, block, release, list, read. Any session may call those. The outcome report isn’t an operation on an issue; it’s a statement about a session. I had to special-case it as the one tool visible only to dispatched sessions, refused from everyone else, recorded against the session rather than the issue. That special-casing was a signal that it didn’t belong there. The session’s end is the business of the components that launch and observe sessions, and they already read a task session’s structured result at exactly that moment.
I made a prompt paragraph a requirement
Two of my requirements say the prompt templates must tell the session to report as its last act. That treats the prompt as an interface. It isn’t. A prompt is advice the model weighs against everything else in context, and the closing paragraph of the opening message carries less weight the longer the session runs. A requirement that an agent “is told to” do something is satisfied the instant the words appear in the template, regardless of whether any session ever does it. It is checkable only in a way that proves nothing.
A schema on the command line is a contract. The harness enforces it whether or not the model attends to it, and a requirement stated in terms of the schema is checkable by reading the invocation.
Authoritative docs made it worse, not better
Our rule is that the design is the source of truth and the code satisfies it. I still think that rule is right. But it means a defect in a requirement is more serious than a defect in code. An implementer who quietly used structured output and dropped the tool would have been non-compliant, and would have failed the tests that compare the default templates against the design page. I didn’t just permit the weakness; I mandated it and put tests around it.
What I should have written
- An issue report schema, alongside the task report schema: an outcome of done, open or failed; a reason when open; a one-line detail. The argument checks I put on the tool become the schema, where a schema can express them.
- A requirement that every dispatched issue session is started with the harness’s structured-output option naming that schema, exactly as task sessions already are.
- A requirement that the supervising component reads the report from the session’s final result and passes it on with the session’s end. The cross-check against the issue’s actual state stays, as a sanity check against the checkout it already reads at that point.
- The merge, strike, hold and alert requirements unchanged, with a guaranteed input instead of a hoped-for one.
- Remove the tool from the issues server entirely, along with its visibility rules, its refusals, the second prompt and the synthetic unreported outcome. A session that produces no final result at all still fails, but that is the harness’s failure and gets specified once for both kinds of session.
- Rewrite the template requirements to end the way the task templates do: report through your structured output, followed by guidance on which outcome to choose. The paragraph stays useful as guidance. The requirement stops resting on it being obeyed.
Then, and only then, the code follows.
The pattern I’ll watch for
This surfaced in one prompt template, but the problem was in the requirements, and it will recur there if I don’t name it. The shape is:
- a component depends on an agent performing a specific final action;
- the action is requested in prose, in a prompt or a requirement that says the agent “reports”, “calls” or “ends with” something, and nothing at the harness, tool-schema or process boundary requires it;
- the design then adds requirements for recovering from the action being skipped, instead of removing the possibility;
- and a mechanism that would make the action unskippable already exists, often already required elsewhere in the same document.
From now on, whenever I write that an agent will do something “as its last act”, I’m going to stop and ask two questions. What happens if it doesn’t? And is there a way to make “doesn’t” impossible rather than merely handled? If the answer to the second is yes, the requirement is the wrong design, and the fact that the implementation complies with it is not a defence.