Series II: From infrastructure to agentic projects in production. Episode 16 of 20.
The fictional B2B portal featured in the series can be monitored and recovered. There’s still an operational challenge: what should an agent do when it sends a request but doesn’t receive a response? For an SME, the prudent decision is to define a verifiable action contract before giving the agent write access. Retry logic must be designed into the service, not left to the model’s intuition.
A dropped connection does not prove failure
An API (application programming interface) lets a program request data or perform operations in another system. In our hypothetical scenario, the agent integrated with the portal creates a request linked to a document, at the direction of an authorized user. The server saves it, but the connection drops before the agent receives a response.
An timeout is when the waiting period expires. A retry is an attempt to repeat the operation. If the agent immediately sends another create request, it may generate two requests for the same intent. Not seeing a result doesn’t mean the first operation didn’t have an effect.
This ambiguity is also discussed in the classic paper by Birrell and Nelson on remote procedure calls, published in 1984: a communication error can leave the client uncertain whether execution occurred. It’s a conceptual reference, not a critique of modern agent systems.
The contract describes a single action
We propose a 'create request' action, distinct from read, edit, and approve. Its contract should be understandable to a developer, validated by the server, and usable by the agent without guessing the rules.
Field | Portal proposal |
|---|---|
Inputs | Title, existing documents, and intent identifier |
Identity | User and organization verified by the server |
Conditions | Documents belong to the organization and are accessible to the user |
Result | Stable request identifier and operation status |
Retry | The same intent and data do not create an additional request |
Verification | A read operation shows the status, with identical access controls |
We define the required fields, length limits, accepted values, and possible errors. OpenAPI is a standardized format for describing HTTP APIs, the protocol used by web services. Specification 3.2.1 was published on September 10, 2026. We choose the version compatible with project tools; the description itself does not implement validation or security.
The key tracks intent, not how the agent phrases it
Idempotency means that repeating the same operation has the same intended effect as executing it once. It doesn’t require every log entry or response to be identical. RFC 9110 cautions against automatically retrying non-idempotent requests unless it can be proven safe. The HTTP POST method, commonly used for creation, does not inherently provide this guarantee.
For the portal, we propose an idempotency key generated before the first attempt and reused for the same intent. If interrupted, the client reuses the original key and data. It does not generate a new key just because the agent has rephrased its explanation. A genuinely new request, expressly made by the user, gets a different key—even if the document and title are the same.
The server associates the key with the caller, organization, and action, and compares relevant data. The same key with different data is rejected as a mismatch. The key is not an authentication secret and should not contain personal data.
In this example, after a lost response, the agent checks the known operation or repeats the request according to the contract. It receives the identifier for the already created request and presents it to the user. If verification is unavailable and retry protection cannot be confirmed, the agent reports the result as unknown and requests human verification—never inventing either success or failure.
Concurrency and the duration of protection are explicit
Two attempts may arrive simultaneously. A simple 'does the key exist?' check followed by creation could allow both to proceed. We propose a uniqueness constraint in the database and a transaction, a group of changes confirmed together or not at all, for registering the key, creating the request, and saving the result.
For an operation still in progress, the response indicates the status and how it can be checked, without starting another creation. The final result remains linked to the same request. We separate the intention identifier from the identifier of each attempt, which is useful in execution logs.
The contract specifies how long the server retains the keys. After expiration, repetition may be treated as a new operation; the client checks the previous result or requests intervention, rather than resending blindly. Stripe API v1 documents retaining results after execution starts, including for certain error responses, and the possibility of deleting keys after at least 24 hours. That is the policy of that API, not a universal rule for the portal.
External effects require their own safeguards
The database transaction does not automatically include email sent by an external provider. We propose durable recording of the notification to be sent alongside the request, then processing separately and verifiably. The service handling the notification must recognize retries, and the external integration should prevent duplicates or reconcile results with the actual state.
We do not promise 'exactly once' execution across all systems involved. The reliable part is the concretely tested limit: a single request created for the same intention, under the conditions and within the timespan of the contract. Notification and other effects are tracked separately.
We also tie this register to recovery from a previous incident. Restoring an older database can erase the record of an operation already executed in another system. After such an incident, we reconcile states before automatically resuming work; the existence of the key in a lost copy no longer prevents a replay.
Errors indicating the next step
The response provides a stable error category, the fields to be corrected, and the operation identifier, without credentials or sensitive internal details. Invalid data requires correction; insufficient permissions require stopping or clarification, not continuous retries. An operation accepted for processing is not presented as completed.
For transient errors specified by contract, we use limited retries and exponential backoff with small randomization, called jitter, to prevent simultaneous retries. We honor the Retry-After, when provided and applicable. We also set the deadline after which the agent stops retrying and reports uncertainty.
The server limits call frequency and the number of simultaneous operations for each client. These limits protect capacity and budget, but do not replace duplicate checks.
Authorization remains the server's responsibility
The server checks access for each document and request, including reading a saved result. The organization identifier sent by the agent does not constitute proof of membership. If OAuth is used, as a delegated access mechanism, we limit tokens to the required resources and actions, following RFC 9700 guidelines.
An dry-run is an explicit simulation designed to show validations and intended effects without making changes. It is not by default available in every API and does not automatically reserve the verified state. For operations with high impact, human confirmation must be tied to the exact data, and conditions rechecked before execution.
Acceptance testing before agent access
We test lost responses after saving, concurrent attempts, the same key with changed data, access from another organization, and expired keys. We check the number of requests and the status of external effects, not just the success message. The contract and these tests are the usable output of the episode.
The development agent can implement the contract; the agent integrated into the portal consumes it with a distinct identity. An MCP (Model Context Protocol) adapter connects tools without replacing these controls. The next episode will check whether even the website interface can be properly used by agents, not just the API.
Sources
Sources verified as of October 17, 2026:
- RFC 9110, HTTP Semantics, June 2022, section 9.2.2, on idempotence and retrying requests.
- Stripe, Idempotent requests, on API v1 policy, keys, results, and expiration; the page contrasts API v2 behavior.
- AWS Builders' Library, Making retries safe with idempotent APIs, on intention identification and concurrency, and the Transactional outbox pattern, on durable notifications and idempotent consumers.
- PostgreSQL 18, Transactions and Unique Constraints, on atomic commit and uniqueness in the database.
- OpenAPI Specification 3.2.1, September 10, 2026, for contract description.
- RFC 9700, January 2025, section 2.3 and OWASP API1:2023, Broken Object Level Authorization, for access limitation and object verification.
- Birrell and Nelson, Implementing Remote Procedure Calls, ACM Transactions on Computer Systems, February 1984, especially section 3.1; the text of the paper.
Design APIs with controlled effects
Want APIs that agents can use with controlled effects? Talk to i8 about integration, verifiable contracts, and safe retries.



