Goal Routing: Deciding Permissions and Done Criteria by Request Type
Routing is not about labeling a request. It first determines which side effects this request authorizes and what evidence counts as done.
On this page · 20 sections
Goal routing is most easily misunderstood as a classifier: see “design” and enter Design; see a PR URL and enter PR Review.
In a real development workflow, the more important job of routing is not recognizing nouns but settling three things: what outcome the user wants, which side effects are permitted this time, and what evidence is needed before completion can be claimed.
If those three things are not settled first, an Agent naturally tends to chain adjacent actions together: Commit once the code is fixed, Push after the Commit, open a PR after the Push, and carry on to deployment once the Pipeline is green. Each step is technically reasonable, yet the chain as a whole exceeds the original authorization.
The Short Version
- Routing is not a keyword classifier. It first settles three things: the outcome the user wants, the side effects permitted, and the evidence needed to claim completion.
- Goals are split by “whether the consequences have entered a new trust domain,” not merged because the operations look continuous.
- Routing selects the contract; it does not write the plan on the model's behalf. The model keeps its judgment within the boundary.
- Composite Goals keep their internal confirmation points, and only ambiguity that would change the Goal or the level of side effect is worth a question.
The thing being routed is not a Topic, but a Goal Contract
An executable Goal contains at least five fields:
goal the user outcome to deliver this time
read_scope which sources may be read and analyzed
write_surface whether changes are allowed locally, in Git, at a Provider, or in the runtime environment
stop_boundary the step at which work must stop
proof which facts are sufficient to support "done"
For example, “implement a fix” and “commit this fix” may both require reading code, running tests, and inspecting the Diff, but their write surfaces differ. In the table below, compare the “Explicitly excluded” column in particular:
| Goal | Main permitted actions | Explicitly excluded | Evidence of completion |
|---|---|---|---|
clarify |
Read the requirement sources; organize known facts and the single blocking question | Design, code changes, external writes | A clear boundary, or one answerable question |
design |
Explore the code and produce a decision-complete plan | Implementation, Commit, Jira writes | Key decisions, impact scope, verification, and risks |
impl |
Modify the accepted scope and verify locally | Commit, Push, PR, Deploy | The actual Diff and the results of relevant checks |
local-review |
Read-only inspection of the current Diff | Fixing findings, committing results | Evidence-backed Findings, or an explicit statement of no findings |
commit |
Commit the accepted scope on a Feature Branch | Push, PR | Readback of local HEAD and the Commit contents |
push |
Non-force push of the Feature Branch | PR, Merge, Deploy | The remote Ref points to the expected Commit |
pr-submit |
Verify, Feature Commit/Push, prepare the PR preview | Unconfirmed Provider writes, Merge | An exact preview; after confirmation, PR Readback proves the write |
release-verify |
Read-only check of deployment and runtime status | Initiating a deployment | Readback of the Release, the Commit, and the real entry point |
The same verb can also map to different Goals. “Take a look at this PR” is usually Review; “open a PR for this change” is Delivery; “the PR failed, find out why” is Diagnose. Routing cannot just match keywords; it also has to consider the expected outcome and the side effects.
Why the cost of undoing determines authorization granularity
Local edits, Git history, remote collaboration objects, and the production environment have different costs of undoing. The further down the table, the harder the recovery and the wider the blast radius:
| Action | State it changes | Recoverability | Blast radius |
|---|---|---|---|
| Editing a file | The current Worktree | Usually recoverable through the Diff | The current operator |
| Commit | Local history | Can still be adjusted locally | The current repository |
| Push | The remote Ref | Often requires a follow-up fix; rewriting history affects others | Consumers of the branch |
| Creating a PR / commenting | Provider objects and notifications | Can be closed or amended, but the notifications have already gone out | The collaborating team |
| Merge | The shared mainline | Can be Reverted, but downstream may already have pulled | All developers |
| Deploy / Data Mutation | The runtime environment or real business state | A rollback does not necessarily undo the impact in the interim | Users and the business |
So Goals should not be merged according to “whether the operations look continuous,” but split according to “whether the consequences have entered a new trust domain.” There are at least four boundaries here:
- Worktree to local Git;
- local to Remote;
- Remote to Provider collaboration objects;
- code to production, which is an independent boundary all the more.
How Marshall's routing lands in the implementation
The mature version of Marshall expressed routing in several layers, each with a different responsibility:
routes/README.mddescribes the entry points and stage relationships in a form humans can understand;commands/marshall/*.mddefines the inputs, outputs, and refusal boundaries each Goal accepts;stage-graph.yamlis the actual execution authority for nodes, Barriers, and Transitions;- the Runtime accepts only the Stages and Transitions that exist in the graph; a caller cannot widen them ad hoc.
There is an important principle here: routing is responsible for selecting the contract, not for writing the plan on the model's behalf.
The impl contract can let the Agent discover the affected modules, choose the tests, and adjust implementation details on its own. It constrains only three things:
- the Agent cannot Commit in passing;
- it cannot write files outside the scope;
- it cannot describe unverified behavior as done.
This preserves the model's judgment while fixing the side-effect boundary.
The routing algorithm: judge the consequences first, then the content
The routing order is not “classify the intent first,” but the following four steps:
1. Find the outcome the user explicitly stated
Read the literal goal first: answer, diagnose, plan, implement, review, commit, push, open a PR, merge, deploy. An explicit verb outranks “what the full process would usually look like.”
2. Identify the largest side effect in the request
If the request says “fix it and Push,” the largest authorized side effect is a Feature Push; if it says only “fix it,” the largest side effect is still a local edit. Permission cannot be inferred from tool availability.
3. Separate necessary prerequisites from a new Goal
Reading code and running tests before implementing is an internal prerequisite of completing the implementation; pushing after implementing is not. Checking the branch and Diff before PR Submit is a delivery prerequisite; Merge is not. The test is: without this step, could the current Goal still be honestly completed?
4. Write down the stop condition for the current Goal
Stopping does not mean “the model has nothing left to do”; it means the authorization boundary has been reached. For example, when the full PR Payload is ready but the Provider Write needs confirmation, pausing at that point is correct completion, not an unfinished flow.
Composite Goals must also keep their internal boundaries
Some teams define a common set of actions as a composite goal. pr_commit in Marshall is such a compatibility composite:
Composition does not mean the authorizations are kneaded into a single “Yes.” The Feature Commit/Push comes from the user invoking that composite Goal; actually creating or updating the Bitbucket PR still requires confirming the current title, body, Reviewer, source branch, and target branch. Once the Payload changes, the old confirmation cannot be reused.
This kind of internal pause guards against a dangerous misreading: interpreting “I agree to this workflow” as “I agree in advance to anything the workflow generates in the future.”
Only Material Ambiguity is worth a question
Routing that is too conservative makes the Agent ask at every step and ultimately produces Approval Fatigue, that is, users worn down by frequent confirmation requests until they stop reading them. What works is distinguishing discoverable facts from genuine user choices:
- the current branch, existing PRs, test commands, and affected files can be discovered with tools;
- an either-or product behavior, whether to widen the scope, and whether to trigger an external write cannot be guessed;
- small implementation details can be decided by the Agent within the boundary;
- ambiguity that would change the Goal or the level of side effect must pause.
The mature version also designed the Question Gate around a single active question: do the safe, read-only exploration first, and only a Material Choice that still cannot be discovered enters the Gate; only one question is held open at a time, so that a string of uncertainties is not offloaded onto the user.
Common failure modes
1. Intent Escalation
“Take a look” gets automatically escalated into a fix, and “fix” gets escalated into delivery. The remedy is not adding one more line saying “do not overstep,” but having every Goal explicitly list its Stop Boundary.
2. Alias Drift
Aliases such as review, local_review, pr-review, and pr_commit map differently in different files, so the same request takes two paths. Aliases must be normalized first and then enter a single Goal Map, with tests checking that every Target resolves.
3. Capability-driven Routing
Because the Agent can use Git, Bitbucket, or AWS, tool capability gets treated as authorization. This is a classic Confused Deputy: the system holds the capability, but the current user intent has not granted it.
4. Completion Leakage
Passing tests in impl get interpreted downstream as push or deploy being complete. Every Goal must define its own Proof and cannot borrow the success status of an adjacent stage.
5. Requiring confirmation for everything
Putting reading files, editing the accepted scope, and running local tests behind approval as well trains users to click confirm out of habit, so the truly high-risk Gates lose their attention. Actions that are low-risk, recoverable, local, and in scope should be as autonomous as possible.
How to test a router
Router tests should not consist only of keyword samples; they also need to cover the boundaries:
- when one sentence contains several actions, whether the largest authorized side effect is identified;
- whether a PR URL enters different Goals in a “review” context versus an “update” context;
- whether
commitnever automatically includespush; - whether
release-verifyis always read-only; - whether an unknown alias Fails Closed (that is, is rejected outright) instead of guessing the nearest Stage;
- whether a change to the external Payload invalidates the old confirmation;
- whether, once the current Goal is complete, work stops rather than automatically selecting the next Goal.
A good Router does not need to be clever, but it must be predictable. The genuinely open-ended work is left to the model; the authorization boundary is left to a very small, testable mapping.
Where it applies, and the trade-offs
When an Agent can only answer questions, Goal Routing is just product experience; when it can edit code, write to Providers, deploy, and operate on data, Goal Routing is part of the permission model.
Its cost is added pauses at high-consequence boundaries, and it requires the product to break a vague “done” into several observable states. The benefit is that every authorization corresponds to a clear cost of undoing and a clear level of evidence, so the model can be more autonomous within the boundary instead of asking for consent before every tiny action.
References
- Running Codex safely: using technical boundaries to separate low-risk autonomous actions from high-risk actions that need explicit authorization.
- OpenAI Agents SDK: Agent orchestration: the differing determinism and applicable scenarios of LLM routing versus code routing.
- OpenAI Agents SDK: Human-in-the-loop: pausing tool calls, per-call approval, and state persistence and resumption.
- Trustworthy agents in practice: the Agent, Harness, Tools, and Environment jointly determine real behavior and risk.
Related notes
Agent Architecture: Should the Program or the Model Decide the Next Step
The difference between Workflow, Autonomous, and Hybrid is not the framework but who decides the next step. This article covers when each pattern fits, how each one fails, and a selection method that starts from task conditions.
Five Questions to Answer Before Putting Agents into Production
Cost and risk, who holds control, how delivery is verified, which layer owns model calls, and how it is evaluated after launch: answer these in order before writing Agent code.
Working on something similar?
I'm always happy to compare notes on distributed systems, delivery, and applied AI.
[email protected]