# The arranger's job is to decide for the model where it should stop

Date: 2026-09-14
Category: Interview Preparation
Tags: Agents, Orchestration, Engineering Trade-offs
Summary: From single-agent setups and state graphs to tool interfaces and human intervention, a retrospective on why long-running agents ultimately rely on centralized control, audit trails, and hard limits to run reliably.

It took me about two days the first time I got business logic running end-to-end through an Agent. It took nearly two months before I could let it run for thirty days straight without incident. In the end, what got me there wasn't better prompts—it was taking most of the decision-making out of the model's hands and turning it into explicit workflows.

What I changed over those two months wasn't mainly the code—it was my understanding of "automation."

## An Agent loaded with tools starts falling apart by step five

The initial idea was natural: take a sufficiently strong model, give it a pile of tools, and let it decide which one to call. Simple, elegant, and it demos well.

Problems started around step five. With a dozen-plus rounds of tool results piled up in context, the model began missing earlier constraints, retrying the same parameter over and over, or simply forgetting the original task goal. This isn't a model capability issue—context windows have capacity limits, and every model has them.

Splitting into multiple roles helped. Not because each sub-Agent was stronger, but because each only had to care about a small slice. The planner only looks at the goal and available capabilities; the executor only looks at its own handful of tools. Shorter context means more reliable instruction-following.

Another more practical motivation was too many tools. An Agent with fifty tools shows a clear drop in call accuracy—it keeps picking the wrong one among similar tools. Split by domain, each role faces only three to five tools, and the error rate drops immediately.

The cost is complexity. A monolithic setup has one process, one log, one config; multi-agent means handling message passing, state sharing, failure retries, and cross-role consistency. The price paid for stability is worse observability—when something breaks, you have to trace the chain segment by segment. I once picked up a production issue and finally traced it to two roles disagreeing on the definition of "done"—I spent half an hour digging through logs.

Then there's the choice between centralized and decentralized. The former has an explicit orchestrator that knows which step the whole flow is at and who should do what; the latter lets roles trigger each other via messages, with no one watching the whole picture.

I basically only use the former. The reason is practical: enterprise workflows need traceability—when something goes wrong, you need to say which step it was and who decided it. Centralization provides that thread, with centralized logs, centralized state, and a place to roll back from. The cost is that the orchestrator becomes a single point of failure—if it dies, the whole flow stops—so it itself must be extremely simple, ideally doing only routing and carrying no business logic.

The benefit of decentralization is that one role failing doesn't necessarily drag down the whole system, which suits scenarios where steps are naturally loose—like a bunch of independent analysis tasks running in parallel. But its observability is poor: when two roles are waiting on each other, it's hard to see where things are stuck. I've been burned by this, and later added a side-channel observer specifically watching messages—which effectively brought centralization back.

## Chained calls have no way back; state graphs do

The problem with chained calls is that there's no way back. Step one to step two to step three—if any step in the middle fails, the whole chain breaks, or you can only carry the error into the next step and let it keep running with the error.

Real business isn't like that. Write something wrong, you rewrite it; can't find it, you switch keywords; the user changes requirements mid-way, you need to go back a step. All of this requires loops, conditional branches, and the ability to pause at any point.

So I basically use state graphs now. Nodes are execution units, edges are transition conditions, and an explicit state object flows through the whole process. That state holds three kinds of things: message history, control markers (like retry counts and the last error), and the artifact being built.

```python
class AgentState(TypedDict):
    messages: list[BaseMessage]   # 对话与工具返回
    draft: str                    # 正在构建的产物
    last_error: str               # 上一次失败的原因
    retry_count: int              # 循环控制
```

Writing it as code has a direct benefit: you can see where it went wrong. A chained call error only tells you this step failed; a state graph error shows you the entire state at that moment—replay it and you can reproduce it. Debugging goes from guessing to looking.

```mermaid
stateDiagram-v2
  [*] --> 规划
  规划 --> 执行
  执行 --> 检查点: 成功
  执行 --> 恢复: 失败
  恢复 --> 规划: 未超重试
  恢复 --> 等待人工: 超限或不可逆
  检查点 --> 规划: 未完成
  检查点 --> [*]: 完成
  等待人工 --> 规划: 确认后继续
```

The cost is high upfront design effort. Drawing a state graph means thinking through every branch, including those "won't happen under normal circumstances" branches. Ship it without thinking it through, and you'll inevitably get stuck on some branch.

It also solved something I hadn't anticipated: observability. Every transition leaves a record—which node, what input, what output, how long it took—and strung together, that's a complete execution trace. When troubleshooting, you no longer ask the model "why did you do that back there"—you just look at the trace and see which step it went wrong on. This value only shows up once the system gets complex; in a monolithic setup it's almost never used.

And it's precisely because of the trace that I dare let it loop. A loop without records is spinning in a black box—nobody knows how many times it's gone around. With records, the worst case is just spending a bit more money, then pulling out that trace and fixing it.

## If the tool description is unclear, the model will call it at the wrong time

When I did full-stack work, interface design was instinct: what parameters a function takes, what it returns, how errors are represented. Now this has taken a different form—it's become "how the model understands this tool."

For the same functionality, if the tool description is vague, the model will call it at the wrong time, or pass a bunch of plausible-looking but business-invalid parameters. This isn't the model's fault—it's poorly designed interface. Name, description, parameter constraints, when not to use it—all of this needs to be written clearly, just like writing API docs for humans, even stricter, because the person reading the docs won't ask questions.

This is where protocols like MCP (a protocol that lets models call external tools uniformly) earn their value. It decouples tool implementation from model invocation: tools run on an independent server, exposing capabilities and permissions through a standard protocol, and the model side only recognizes the protocol. Swap models without rewriting tools; swap tools without changing prompts.

What I value more is the permission layer. Handing the entire database connection string to an Agent is dangerous; exposing only a few restricted queries through the protocol is far less risky. This is the same idea as backend service boundaries—except now the served party has changed from a service to a probabilistic caller.

Transport also involves trade-offs. Running locally, use stdio—simple, low latency, no network exposure; remote or multi-machine deployment goes over SSE (server-sent events), but requires more thought around authentication and timeouts. I lean toward local by default, only exposing outward when sharing is genuinely needed.

Retrieval is actually part of orchestration too, and it's the part most easily treated as "configure it once and forget it." Pure vector retrieval is weak at exact matching—product model numbers, function names, order IDs—semantic similarity doesn't help there. So any workable solution basically has to mix in a keyword retrieval path, then rerank the merged results.

Another detail is chunk granularity. For content matching, chunks should be small for more precise hits; what's handed to the model should be the larger passage the chunk belongs to, otherwise it reasons from half a sentence. This parent-child structure isn't complex, but without it, answers often wobble between "looks right" and "completely wrong."

Before retrieval there should also be a judgment: is the existing information enough? Some questions can be answered from existing context, and forcing a retrieval instead introduces irrelevant material that muddies otherwise clear reasoning. My approach is to add a judgment node: first assess whether existing information suffices, and only search if not; after searching, check relevance, and if it's poor, rewrite the query and retry rather than forcing a generation.

Retrieval conflicts are another unavoidable situation. When two sources say opposite things, letting the model pick one is the worst handling—it picks with no justification. More reasonable is weighting by time and source, or in analytical tasks, honestly presenting the disagreement—the user needs to know the matter itself is disputed, not get a smoothed-over answer.

## Being able to stop is what separates Demo from production

This is, I think, the clearest dividing line between "built a Demo" and "shipped to production."

Infinite loops are almost certain to happen. The model calls an API, the parameter format is wrong, it gets an error, assumes it will succeed next time, retries with the same parameters, and keeps going until it exhausts the context. At every step of the process, it is completely confident.

So hard limits are mandatory: maximum steps, maximum retries, and a token budget per session. When triggered, terminate immediately—don't expect the model to figure it out on its own.

Even better than hard limits is translating errors into plain language and feeding them back. If you just throw a 500 or a stack trace at it, the model most likely won't understand; but if you replace it with "The last attempt failed because the date must be in the future. Please modify the parameters and retry," the probability of it fixing the issue itself is quite high. This change is small, but the difference in effect is large.

A more proactive approach than hard limits is supervision. Run a separate lightweight checking node that does no concrete work and only watches the execution trace: if two consecutive steps call the same tool with the same parameters, intervene and inject a line: "This path has already failed. Try a different approach or confirm with the user." It doesn't need to be very smart; rules alone can catch most infinite loops.

Human intervention points need to be defined in advance, not patched in after something goes wrong. I divide them into three categories: read-only operations execute directly; operations with side effects but reversible—after execution, show the human a summary; irreversible ones, such as transfers, sending emails, deleting data—must stop and wait for confirmation before execution.

There is an easily overlooked engineering prerequisite for stopping: state must be persistable. A human might come back half an hour later to click approve; during this time the process cannot hang, and a service restart must not lose pending approval tasks. So state must be persisted to a database, and when resuming, continue from the breakpoint. This sounds like an infrastructure problem, but in practice it determines whether this feature can actually be used.

There is also a category: correction. When a human sees that an intermediate result is wrong, they want to modify it and let it continue, rather than starting over from scratch. This requires a snapshot of the state at every step, so it can return to any point and proceed again. It's troublesome to implement, but it's the difference between "human in the loop" and "human watching from the sidelines."

There is another situation: the answer is too fluent, and you can't tell it's making things up. What's needed then is external checking: whether the retrieval results match the answer, whether key numbers have sources, and when two sources conflict, whether to weight them or honestly present the disagreement. These are all judgments at the orchestration layer and should not be left to the generation step.

> What enterprise systems often want is not 100% automation, but 100% controllability.

My current judgment is that the core capability of this role is not whether you know how to use a particular framework. Frameworks change every year; after LangGraph there will be others. What truly remains is: knowing which step should be left to the model to decide, which step must be hard-coded, and where the system should fall back when something goes wrong.

In this job, the most valuable action is often taking back some permissions. The earlier you take them back, the less trouble later. The model's capabilities will keep growing, but it will never know whether it should stop.

This judgment cannot be copied from documentation. You can only launch it yourself a few times, get burned by your own Agent a few times, and then remember that feeling. Next time I draw a state diagram, I will first circle the nodes that must stop and wait for confirmation, and then discuss the automation rate. If this order is reversed, rework is usually required.

Further reading: [Shipping Agents Is Hard—The Hard Part Is the Shell Outside the Model](/2026/11/01/stop-worshiping-prompts-in-2026-the-core-moat-of-top-agents-is-harness/)
