Imagine a document-processing agent uploading a signed contract and reporting “Done.” The upload succeeded, but the indexing job has not finished. The next agent searches for the contract, finds nothing, and tells the sales team that the customer has not signed yet.
Nobody needs to invent a fact for this workflow to go wrong. The upload tool can return a successful acknowledgment. The search tool can correctly return an empty list. The mistake happens when the workflow treats those two results as evidence about whether a customer signed a contract.
The file has reached one part of the system. The next step depends on another part being ready.
This gets harder to notice when each component has its own reassuring status. An upload is accepted, a worker finishes processing, a status endpoint returns 200, and the agent moves on. None of those signals necessarily means the newly uploaded version is available through the search path that the next agent uses.
What did “Done” actually promise?
For this workflow, there are at least three different things an acknowledgment might mean:
| State | What has happened | What it does not establish |
|---|---|---|
| Accepted | The service saved the upload and acknowledged it | Processing has completed |
| Processed | The worker reached its completion marker | Search can retrieve the result |
| Searchable | The required version is visible through the relevant search path | A particular query will find it, or its contents prove a signature |
The distinction belongs in the tool response. If the tool returns only {"success": true}, the next agent has to infer which promise was made.
A more useful upload acknowledgment identifies the operation and the exact version being processed:
HTTP/1.1 202 Accepted
Location: /operations/op-123
Content-Type: application/json
{
"operation_id": "op-123",
"document_id": "contract-104",
"version": 2,
"state": "accepted"
}
202 makes the acknowledgment more explicit, but changing the status code alone does not fix the workflow. The caller still needs to follow the operation. Microsoft's asynchronous request-reply pattern describes this arrangement: acknowledge the request, provide a status endpoint, and report progress separately from the initial response.
The user-facing message can be just as direct:
The upload was accepted. It is still being prepared for search.
That tells the sales team what has happened without promising that every downstream step is ready.
Two successful HTTP calls, one wrong conclusion
To make the gap observable, I ran a small local HTTP pipeline with an asynchronous worker, a source database, and a separate SQLite full-text search index. A scripted caller uploaded a contract fixture, then searched for it. The fixture included a known signed or unsigned value so the resulting answer could be checked.
The run used Python 3.12.3 and SQLite 3.45.1. There were no model calls or PDF signature checks; it tested the workflow's handling of tool results. The processing and visibility delays were injected, including a separate interval between the worker's completion marker and publication into the search index.
Here is one recorded sequence from the delayed-visibility case. Times are rounded and measured from the start of that run:
27 ms Upload response: 202, state=accepted
30 ms Search response: 200, hits=[]
34 ms Caller reports: not_signed
46 ms Worker sets its completion marker
274 ms Uploaded version becomes searchable
The search response at 30 ms was accurate. The file was not in that index yet. The unsupported step was converting an empty result into not_signed.
This distinction also exists in real search products, although the timing and guarantees depend on the product. Elasticsearch, for example, documents that an indexing request can return before a refresh makes its changes visible to search. Its refresh=wait_for option waits for that visibility before replying. The local test models the gap; it does not measure Elasticsearch's behavior or performance.
Waiting a little longer helped, until it didn’t
You might reasonably ask whether a short wait would be enough here. For a small internal tool where a missed result just means trying again, that can be a sensible compromise. The problem is what the caller concludes if the search still comes back empty.
The experiment compared three caller policies:
- Immediate search: search as soon as the upload is acknowledged.
- 100 ms wait: wait, then search.
- Version check: check the operation for the uploaded version, then search only when that version is visible. Stop polling after a 300 ms budget if it is still pending.
The first two policies deliberately use the unsafe rule from the opening scenario: an empty result becomes “not signed.” The third keeps processing failures, unfinished work, and inconclusive retrieval separate from a signature answer.
Each combination ran three times: 72 scenario runs and 441 HTTP requests. All three repetitions produced the outcomes below.
| Condition | Immediate search | 100 ms wait | Version check |
|---|---|---|---|
| Fast indexing | Not signed | Signed | Signed |
| Slower processing | Not signed | Not signed | Signed |
| Worker finished, visibility delayed | Not signed | Not signed | Signed |
| Processing fails | Not signed | Not signed | Processing failed |
| Processing exceeds the polling budget | Not signed | Not signed | Pending |
| Older unsigned version is already visible | Not signed | Not signed | Signed, using the new version |
| Ready file does not match the query | Not signed | Not signed | Inconclusive |
| Genuinely unsigned fixture | Not signed | Not signed | Not signed, using the requested version |
Except for the final control, each uploaded fixture was marked signed. These are deliberately selected failure cases, not a sample of production traffic or a model accuracy benchmark.
The 100 ms wait repaired the fast case. It could not account for slower processing, failed work, or an unsuitable query. Making the sleep longer would change which timing cases pass, while adding the same delay to uploads that are already ready.
Checking readiness changes what the caller waits for. It waits for a condition associated with this upload, rather than assuming that enough time has passed.
“Ready” needs an identity attached
Let's take another example, because a document can already be searchable and still be the wrong version. Suppose version 1 of contract-104 is an unsigned draft. It is already in search. Version 2 is the signed replacement, and its upload has just been accepted.
A check such as “does contract-104 exist in the index?” will pass immediately. So can a document-level ready=true flag left over from version 1. Neither establishes that the newly uploaded version is ready.
The operation receipt gives the next agent the identity it needs to preserve:
operation: op-123
document: contract-104
version: 2
The status check must refer to that operation. The eventual search result must also match the required version. Otherwise, a workflow can wait correctly and then answer from an older document anyway.
In the local pipeline, the search content and its version-specific visibility record commit together in the search database. The status endpoint uses that record to report whether the requested version is searchable. It does not treat the worker's earlier completion marker as sufficient evidence.
That is a deliberately narrow guarantee. A distributed service needs to establish visibility for the index, generation, or read path the next request will actually use. A worker updating a flag in its own database is not proof that another service, replica, or cache can serve the result.
The status endpoint itself may return 200 while work is unfinished:
{
"document_id": "contract-104",
"version": 2,
"state": "processing",
"searchable": false,
"error": null
}
Here, 200 means the status lookup worked. Reading the response body is what tells the caller that it must keep waiting.
Ready still does not mean the answer is known
The query-miss case is where a readiness-only fix reaches its limit. In that test, the indexed text was “Contract customer signature recorded,” but the caller searched for approved. The document was ready; that word simply was not in it. Waiting longer would not change the result.
That example uses a lexical index to make the mismatch easy to see. Semantic retrieval has its own reasons to miss relevant evidence, so switching retrieval methods does not turn an empty list into proof of absence.
For the specific question “has the customer signed?”, search may be the wrong source of truth in the first place. If an e-signature system or contract registry holds authoritative status, query that record using the contract's identity and the appropriate customer permissions. A file being present, or a parser returning a field, is not by itself verification of a legally valid signature.
Readiness matters when the next task actually needs the uploaded content: summarize the signed document, extract its renewal date, or compare it with the previous version. Even then, the workflow must check that it retrieved the intended version and enough evidence to answer the question.
For an empty result, a useful response is specific about what is missing: “The upload is ready, but this search did not retrieve the contract. I cannot confirm its contents from this result.” That leaves room for a direct lookup or further investigation without telling the sales team something the system has not established.
A deadline should change the response, not the facts
Waiting indefinitely is not a practical solution either. A worker may be slow, fail, or stop making progress.
In the deadline case, the caller stopped polling and returned pending. The worker subsequently finished and the uploaded version became searchable. The caller's waiting budget had expired; the upload itself had not failed. For the sales team, that calls for a message like “The upload was accepted, but it is not ready for search yet,” with a way to check again.
The processing-failure case needed a different response. Its status included the extraction error, so the caller could report that preparation had failed rather than pretending the customer had not signed.
A production workflow needs bounded requests, a total waiting policy, and polling intervals that suit the service. The 300 ms polling budget and short intervals here are test settings. They are not a recommended deployment timeout, and the polling budget alone does not enforce a hard deadline on every network call.
For longer work, keep the operation identity and let a notification or resumed task continue from it. An event saying “processing completed” should still carry the relevant document version and have a documented relationship to search visibility. Changing from polling to events does not remove that requirement.
What to test before calling the workflow complete
A test that only checks the upload response will pass the broken workflow. So will a test that waits for every background job to finish before it lets the next agent run. That second setup quietly removes the timing condition the deployment needs to handle.
Exercise the handoff while the system is in the states that users will encounter:
- Processing and visibility: accepted but not processed, or processed but not yet visible.
- Document versions: an older version is visible while the requested version is still being prepared.
- Failures and deadlines: a job fails, or the caller stops waiting before the job finishes.
- Retrieval and evidence: a ready document does not match the query, or the retrieved version really is unsigned.
That last control matters: the evaluation should check more than whether the agent refuses to answer.
For each attempt, retain the operation ID, requested version, observed status, retrieved version, and final answer. That makes it possible to distinguish a processing failure from a retrieval miss, and both from an unsupported conclusion by the caller. The local run retained those records and passed 12 focused checks covering these boundaries.
You may not have faced this exact scenario, but the handoff matters whenever one service finishes before another is ready. Depending on the next task, you can wait for readiness within a deadline, resume when the required version becomes searchable, or check the signing system directly. The aim is to give the user an answer the available evidence actually supports.
If you've dealt with this as a forward deployed engineer or while deploying a system for a client, feel free to share what happened and how you handled it.


Top comments (1)
Spot-on post, the gap between "the write succeeded" and "the state is actually observable" is a huge blind spot in agent design right now.
But how do we handle cases where indexing latency spikes unpredictably?
Just curios, do you have the agent surface an intermediate state to the user ("uploaded, still indexing") or keep it waiting on a verification check up to a strict timeout.