Deep Agents: What Survives a Failed Agent Run

Outline

Transcript

0:00 Your Deep Agents assistant gets a huge checkout-test log. If its backend returns a write error, the model keeps the original reply. But saving older conversation can fail and still leave the model with a shorter history. Imagine the detail that disappears is, “Another suite reserves port 80 81.” The agent knows the port is occupied. It no longer knows why it must leave that process alone. Yeah. Stopping the listener could make checkout pass and break its neighbor. Both storage operations failed, but only one kept the displaced evidence in the request.

0:32 We traced the public Deep Agents source at version 0.7.19. Links are in the description. Our checkout investigation is invented. Let's follow the actual failure branches, then carry the repair through delegation and an interrupted test. The question is what evidence reaches the next decision. Our developer sees a timeout: checkout waits for a payment mock that never answers. We reach for a bigger timeout. Reasonable, until we discover the mock never started. So we'd spend more time waiting for absolutely nobody.

1:05 Where did its startup error go? Then take the runner's huge log: the error is buried in its middle. Deep Agents can save oversized tool text and substitute a backend path and preview. That preview takes the first five and last five lines by default. Our timeout is at the top; cleanup is at the bottom. Neither explains the startup failure. Yeah, the preview can show the symptom and miss the cause. The size threshold is configurable and estimated from characters. I'd search the saved output for the mock.

1:37 That finds the bind error. But our developer follows the supplied path in a terminal and gets no file. That empty terminal lookup leaves me suspicious. The agent says it read the file, but our developer can't open it. I think the save failed. With the default State Backend, both observations can be true. File records live inside the thread's state. They aren't files in the checkout. Ah. The agent asks its backend for a record; the terminal asks the operating system for a disk file. Same path text, different lookup.

2:09 Yes. Reading through that backend recovers the diagnostic. Before rerunning a completed test, establish where its output went. The apparent missing file hasn't shown us a failed write. But the agent just read the record after writing it. Does that prove we can restart and read it again? No. A State Backend read can include this turn's pending update. Restart recovery needs a checkpoint, meaning a saved snapshot containing the record, and a resume of that same thread. The printed path proves neither step happened.

2:40 Imagine our developer restarting the application from a saved checkpoint. If the record was never checkpointed, that second backend read fails and the bind evidence disappears. The immediate read alone cannot rule it out. Yes. If the first read works and the resumed read fails, the terminal's wrong lookup wasn't the whole problem. Consider the next developer opening a fresh conversation with the same checkout. Can we make the diagnostic available there on purpose? Yes, if the application routes a chosen path prefix to a shared store.

3:12 Temporary paths can remain in this conversation. Deep Agents calls that combination a Composite Backend; the agent still uses the same file tool. Then a path that looks durable is only durable if that route was actually configured. I'd want to read the returned path and inspect the route, not infer storage from the name. Exactly. In our incident, we haven't configured that route for the test output. It remains thread scoped. Would the oversized log automatically land under that evidence route? No. Suppose the route covers the evidence directory while the generated log lands under large tool results.

3:48 That misses the shared store. Future logs can use a configured artifact root under the route; another conversation also needs the same namespace, the store's scope for that record. Neither was configured here. Now test a backend write that actually fails. That reader mismatch raises a second question. Suppose the backend write itself returns an error. What reaches the model? The full tool reply remains model-facing. The helper returns no replacement, so the caller has no saved-result pointer to substitute.

4:19 So we lose the space saving. But the model still receives the diagnostic, which seems like a reasonable way to fail. I agree, within that contract. It doesn't promise the request fits, or that the model notices one line in the noise. And a returned error isn't every possible failure. But suppose that storage implementation raises instead of returning an error. I wouldn't assume the caller treats those alike. Does it preserve the reply in both cases? They aren't interchangeable here. This helper doesn't catch arbitrary write exceptions.

4:51 A raised exception can stop the run before the caller gets that original reply back. So a backend adapter can change the outcome just by how it reports failure. The reassuring phrase “saving failed” hides the distinction. Exactly. In our invented case, saving the log worked, but the next operation fails: archiving older conversation before Deep Agents summarizes it. We put the giant log behind a path. Why is the conversation shrinking anyway? Offloading reduced one tool reply. The next request also carries the conversation and may include system content and tool definitions in its size count.

5:25 Summarization reserves space for the model's reply. The remaining request can still exceed its budget. So the owner warning can fall into older history even though the test log now has an address. Yes. From this point, the question is what the model receives after shortening, not only what the application saved. Could it always summarize again if the request still overflows? No such guarantee. Its overflow recovery can retry with a reduced request, but it raises an error if reduction cannot make the request fit.

5:56 Saving a log elsewhere does not create an unlimited context window. In our case the shorter request does run. That is the unsettling branch: it can act confidently on “port occupied” after losing the sentence that says whose port it is. And the attempted history archive would have been one route back to that exact sentence. Let's see what happens when its write fails. Before summarizing, Deep Agents tries to copy displaced chat messages into a Markdown history file. In our case the write fails, but the original thread record remains and summarization continues. I'm comparing the callers. The log branch retained every line of its tool reply.

6:36 Why doesn't this one keep older messages in the next request? The archiver returns no path on a reported storage error and catches write exceptions too, so summarization can continue despite either failure. So it tries the archive, but it doesn't wait for a successful save before shortening the request. And without that successful archive, the shortened request has no new history-file pointer for retrieving the owner's exact warning. Now take this imperfect summary: “Checkout timed out. Mock port occupied.” The owner had said the other suite reserved it.

7:10 That second fact didn't survive into our invented summary. Then killing that process looks like removing an obstacle. Picture our developer stopping it: checkout turns green, and the neighboring suite loses its listener. Rereading the saved test log won't repair this misunderstanding; ownership came from the conversation. Next, picture this debugging moment: the developer opens the saved conversation, finds the owner's warning intact, and says, “We told you. It's right there.” Yeah, we look at the chat and expect that to be what the model saw.

7:41 I'd compare it with the actual request. The archive failure didn't erase the existing raw conversation. But the model request uses a summary followed by messages after a cutoff. Our warning sits before it, so the application can retain words the model doesn't receive. That's the comparison we needed: saved conversation beside actual request. We can locate the missing sentence without guessing that the model read it and chose to disobey. What happens if we ask another agent to judge the repair? Now the developer asks another investigator to review the proposal that ignored the warning. First they fork the saved thread.

8:19 I can see the appeal. An isolated child starts with a fresh task, not the parent's old conversation. A fork gets the conversation too. Does it recover that warning? No. The fork copies what the parent would actually send: the summary and newer messages. It adds the delegated assignment, but the owner's older warning doesn't come back. Oh, so we've made a second investigator with the same blind spot. Changing who thinks about the evidence doesn't change which evidence they're given. I wouldn't trust that second opinion yet.

8:52 So what does isolated mode carry besides the new task? Does that child at least get the saved log? It can inherit eligible file state, including the log, but not the prior dialogue. The startup error can reach it while the process-ownership warning does not, unless the task repeats that constraint. Then the child could diagnose the occupied port correctly and still recommend stopping the wrong process. The diagnostic and the authority to act are separate questions. Exactly. The child modes pass along different evidence, but neither reconstructs the missing owner sentence on its own.

9:28 Can we put that sentence back into this run without replaying the whole conversation? Now that neither child recovered the reservation, the developer tries a second route: add it to a configured memory file in the saved run. A direct read of that file shows the correction. Then I'd expect the next request to use it. We just saw the correction. But this thread already holds an older copy in its state. While that copy is there, memory middleware doesn't reload the file. So the file changed, but the next prompt still contains the old instruction.

10:00 Hold on. So recover the exact sentence from saved chat: “Another suite reserves port 80 81. Do not stop its listener.” Append that as a new message after the summary cutoff. The next request and a later fork now see it. And enforce it at our custom runner: refuse stop commands before another test. Deep Agents' built-in file permissions do not govern that process tool. Before we trust the earlier isolated child's diagnosis, what came back from it? Its whole working conversation? No. The parent gets a final answer and eligible state updates, including file changes.

10:33 The child's intermediate dialogue is not pasted into the parent's request. Then “I checked” is weak evidence. I want the exact socket-collision line and a findings path in its return, so the parent can reconstruct the reason rather than accept a conclusion. And the port-ownership constraint still needs a separate check. Could the application inspect what the child actually saw, instead of taking that summary at face value? If the application retained the child's checkpoint records, yes. It can inspect that saved child history.

11:04 The ordinary message returned to the parent is still only the child's answer, not its transcript. I'd open the child's saved input and look for the warning verbatim. If it is absent, that explains the unsafe suggestion. Our earlier child never received that warning. When two children report repairs, we'll inspect their returned files and the parent's combined file too. Now that the runner blocks the unsafe stop, two children investigate safely. Both report success and say they reread their changes, yet the parent's repair note still has one old setting.

11:36 Show me the returned files. The first child traced the mock listener. Its complete note says, “Mock uses replacement. Test remains on old port.” So the mock moved, but checkout still points at the collision. The second child traced checkout's destination and returned this complete note: “Mock remains on old port. Test uses replacement.” Wait. That second note drops the proposed mock move. Yes. It landed last and replaced the first whole note. Following it would move the test destination but leave the mock on the occupied port. With both versions on the table, why didn't the framework keep both corrected lines?

12:12 And were those local checks really true? I think the tempting model is a line patch. Its file reducer actually keys by path: a matching path replaces the entire record, not just the corrected line. Each child read its own change before the results merged, so both success reports were truthful. Then we need to read the parent's complete record after both children return? Yes. Check both intended corrections there; the children's local reads cannot verify that combined result. Reverse the merge order and the note loses the test correction instead; the collision survives either way.

12:45 I expected the same-path guard to catch this. Did it? Now test the guard against that collision. It rejects a second edit to one path within a single assistant response. But these edits came back in separate child responses. It saw one change per response and never compared the pair. So both get a clean bill of health, and the parent still has a broken note. We need to change who owns the combined one. We change the assignments: one findings path for the mock, another for the connection. The parent alone will assemble the repair plan.

13:19 Different paths let both findings survive. What do they reveal together? The mock names a replacement endpoint, but checkout's launcher still sends the test to the occupied port through an environment variable. So the parent changes the mock setting and the launcher's active destination to match. The owner's process stays up. How would we turn these failure branches into a repeatable regression test? I'd build a small test program that runs the real Deep Agents code with a fake model and our checkout runner.

13:48 The application supplies the checkpoint saver, and the framework uses it. So we can script the model's replies and control the runner's outcomes, instead of waiting for a live model to stumble into exactly this failure sequence. Right. Take a fixture log with the mock's bind failure buried in the middle. Capture the model-facing preview and read the full backend record. If either claim differs, the reconstruction fails before delegation even starts. Then make the harness check the restored warning and both final endpoint settings, including the launcher override.

14:19 Yes. Capture the actual model request and configuration; the scripted model saying it succeeded proves none of them. Now for the interruption: the runner needs a request identifier and a retained result. Otherwise a missing chat reply could mean the test never ran, failed, or passed. Exactly. Save an agent checkpoint with the call but no reply, and keep the runner's execution record separately. On resume, count runner invocations and query that identifier before deciding whether to execute again.

14:47 Let's interrupt the conversation after checkout is requested, then resume it and ask the runner what happened. Now the parent asks our runner for a focused checkout test. Its saved agent state contains the request, but no reply. When our application starts a new agent invocation from that saved history, what does middleware do with the unanswered call? Patch Tool Calls middleware adds a synthetic error: no result was recorded, perhaps because the call was interrupted. It matches calls and replies in the chat; it doesn't contact our runner.

15:17 So the red message is a conversation repair, not a checkout verdict. Did our runner keep the outcome of that exact request? Then the missing reply sends our developer to the runner with the retained request identifier. It did run: the mock started at the new endpoint, checkout connected, and checkout passed. Only the reply failed to reach the conversation. Oh, good. We lost the reply, not the successful test. Our runner kept that identifier and result, so we can attach the evidence. Now check the side we promised not to break.

15:49 So the developer inspects the reserved listener and runs the neighboring suite's focused test. The listener remains up, and that separate test passes too. Now I would accept the repair. We have the verified reservation, the actual configuration changes, and results for both sides of the promise. Thanks for listening to Learning Podcasts.