Blog Article
When an AI Agent's Salesforce Write Times Out: Recover the Action Without Repeating It
A Salesforce write times out and the AI agent must not repeat it blindly: a proposed recovery decision table, two traces and a test plan.
A support agent has routed an urgent case and is creating a callback task. Then the tool times out. If the AI agent repeats the write, the customer may get two callback requests. If it gives up, the request may be lost. The right next step depends on something the timeout does not tell you: did Salesforce save the task?
This is an unknown-commit problem, not a prompt-writing problem. A useful agent needs a recovery path that preserves uncertainty, finds evidence and limits what it can do next.
The design below is illustrative. Its recovery states, decision table and traces are proposed guidance, not documented Salesforce guarantees. It is not an Incresco client result, a measured experiment or a built-in Agentforce recovery feature. It describes custom orchestration around a Salesforce-connected AI agent. Its central artifact is a decision table for one callback-task operation, followed by two traces of the same failure.
The promise must be smaller than the workflow
In this example, a customer asks for an urgent case to be escalated and for a callback. Assume the authenticated request and policy permit routing the case and recording a callback request. They do not permit promising that a person has accepted the escalation or will call at a particular time.
Salesforce describes Task as a business activity or to-do item. A Task can refer to a Case through WhatId, has an owner and has a status. The actual fields, permitted owners, required values and automation must be checked in the target org. Salesforce Task reference.
A saved Task proves a record exists, subject to what was read and when. It does not prove a phone call happened. A case owner or queue update proves routing was recorded, not that a human received, accepted or resolved the escalation. The agent’s permitted completion language must respect those boundaries.
Define this action before the agent attempts it
The callback action needs a contract narrow enough to verify. For this proposed workflow, it includes:
- Preconditions: the caller can act on this case; the callback request is within scope and permitted for the selected contact channel; the case and intended owner are unambiguous; required fields and the org’s status rules are known. Any required approval is current.
- Intent: record one callback request for this case, this intended owner and this authorised request. A changed owner or materially changed request is not a silent replay of the same action.
- Postcondition: one correlated Task is persisted with the intended case, owner and action attributes, with no unexplained duplicate. This is not the postcondition that the callback was completed.
- Recovery boundary: a named integration recovery service or authorised operator owns reconciliation. The model may request a status check or handoff; it cannot turn an unknown result into permission to create another task.
The agent should receive a structured outcome such as confirmed, unknown or blocked, plus the facts it may report. Those are proposed application states, not Salesforce API response codes.
The recovery decision table
Use this table after a callback-task write has timed out. It is a proposed runbook, not a claim that Salesforce provides these branches automatically. In every row, keep the separately verified routing result intact unless a newly authorised action changes it.
| Evidence after the timeout | Operation state | Allowed next action | What the agent may tell the customer |
|---|---|---|---|
| Authoritative readback finds one Task correlated to this operation, matching the intended case, owner and action; duplicate reconciliation finds no unexplained extra task | Confirmed at the recorded read time | Store the Task ID and readback evidence. Do not create it again. | The callback request was recorded. Do not claim the call happened or the escalation was accepted. |
| A related Task is found, but correlation, case, owner or action does not match, or more than one plausible Task exists | Unknown or conflict | Stop automatic creation. Give the evidence to the recovery owner. Do not merge, delete or repurpose tasks without authority. | The routing update is recorded; the callback request still needs checking. |
| The query returns no matching Task | Unknown | Check visibility, the operation record and whether an original or concurrent write can still finish. No blind retry. | The routing update is recorded; the callback request is not yet confirmed. |
| Readback is unavailable, permission-limited, stale or unsuccessful | Unknown | Preserve the intent and failure evidence. Route to the authorised recovery owner. | State what was confirmed and what could not be checked. |
| Recovery establishes that no original attempt can still commit, no matching task exists within a sufficient visibility scope, and the deduplication controls cover a new attempt | Eligible for a new attempt, not yet complete | Recheck authority, payload and current case state. The recovery service may permit a controlled attempt under the documented integration policy. | Do not report a callback request as recorded until that attempt is verified. |
An empty result belongs in the unknown row, not the retry row. A successful query is not necessarily a complete view: sharing, permissions, an incorrect org or filter, and changes occurring after the query can matter. The last row requires evidence about the original attempt’s lifecycle and the integration’s controls, not simply waiting for an arbitrary number of seconds. If that evidence cannot be obtained, hand off rather than retry automatically.
Two traces, one timeout
These traces use synthetic labels and show expected behaviour. No run was performed and no success rate is implied.
Trace A: the write committed, the response was lost
- Before any side effect, the integration records intent for operation CB-42, including the target org, case, intended owner, authorised action and payload fingerprint. It records which authority allowed the attempt and who owns recovery. The fingerprint detects a changed payload; it does not deduplicate Salesforce writes by itself.
- The case-routing step succeeds. An authorised readback confirms the expected routing fields. That step is recorded separately from callback-task creation.
- The callback create call times out. CB-42 becomes unknown. The agent does not resubmit the create call and does not claim completion.
- The recovery service reads the authoritative records through an authorised connection. A deliberately implemented correlation mechanism identifies Task T-17 for CB-42. It checks the case, owner and action attributes and reconciles possible duplicates. Matching a subject line or a nearby creation time is not sufficient.
- The service stores the Task ID, org, object, relevant returned fields, query time and the access context used for the check. It marks this action confirmed at that time.
- The agent reports only the two verified facts: routing was recorded and the callback request was saved. It does not say that a person has picked up the case or completed the callback.
Trace B: the integration still cannot establish the outcome
The first three steps are identical. This time readback returns no matching Task, or fails because the recovery connection cannot see the relevant records.
CB-42 stays unknown. The agent does not interpret no result as no write. It preserves the confirmed routing change, stops automatic callback creation and requests a handoff to the configured recovery owner. That handoff carries the operation reference, intended case/owner/action, authority reference, attempt times, confirmed routing evidence and the unresolved callback result. It excludes unrelated customer history and secrets.
Dispatching the handoff is another action to verify. If a work item was persisted, report it as queued for review. Do not call it accepted until the receiving workflow supplies that evidence. If dispatch fails, retain the unresolved work in the integration’s recovery queue and surface the failure to its operator rather than tell the customer that someone is handling it.
Before any later attempt, the recovery owner checks whether the customer withdrew the request, whether consent or permission changed, whether another worker already acted and whether the case or intended owner changed. Old permission is not an unlimited replay grant. Material changes require a new decision, not reuse of the old payload under a familiar operation ID.
The ledger does not close the crash window
A durable operation row is useful because it preserves intent and recovery ownership across a process failure. It is not proof that the Salesforce Task exists.
There is a crash window between saving local intent and sending the write, and another between Salesforce committing the write and the integration saving the response. A row left in an in-flight state may represent either. A process restart cannot safely resolve that ambiguity from the row alone.
This design therefore requires an implemented correlation and reconciliation mechanism. If the integration cannot correlate a Task created before a response was lost, it has not earned automatic replay. Keep that path in supervised recovery. A unique local operation key does not make the remote Task create idempotent, and this article assumes no Salesforce Idempotency-Key header for it.
Salesforce documents upsert and retrieval by external ID. Its upsert behaviour depends on whether zero, one or multiple records match. Those facilities can inform a custom operation-record design after the exact object, field configuration and API are verified. They do not establish that Task supports a chosen external-ID scheme, that ledger and Task writes are atomic, or that a retry cannot trigger other automation. Upsert documentation and retrieval by external ID.
We deliberately leave the concrete correlation implementation unresolved here. Choosing it requires the target org’s schema, automation, access model and integration transaction boundaries. Do not paste a generic wrapper around create-task and call that exactly-once execution.
Test the recovery table, not a reassuring reply
The useful test artifact is a set of injected failures against the table. In a controlled environment, arrange for a write to commit while its response is lost, crash the integration before the remote call, crash it after the remote commit, restrict readback visibility and introduce a conflicting or duplicate Task. Also change the authorised owner or withdraw the request before recovery.
For each fixture, assert the allowed next action. An unknown result must not produce an automatic create call. A correlated confirmed Task must not be recreated. A conflict must reach the recovery owner. A queued handoff must not be described as accepted. Preserve the evidence needed to review each verdict, with appropriate access controls and retention limits.
OpenAI’s trace-grading guidance supports examining an agent’s decision and tool trace. Anthropic’s evaluation guidance distinguishes a claimed outcome from the actual state in the environment. Neither makes a model’s judgment proof of a remote transaction. Deterministic record checks should decide the persisted-state assertions; a carefully checked semantic grader can help assess whether the reply overclaims.
This is a proposed test plan, not a benchmark result. It cannot prove universal correctness, and tests need to cover the actual automation and access rules of the target org.
What this adds to the existing guides
Incresco’s ThinkingBox article explains why end-state checks matter. The Claude Code harness guide covers a general execution and verification loop. The AX engineering guide covers API error design, idempotency and handoff patterns.
The narrower contribution here is the callback-task recovery table: which evidence permits which action after an unknown commit, including the branch where automation must remain stopped. The runtime decision is the subject, not another general account of retries or agent evaluation.
How Incresco can help
If your support agent can write to Salesforce, choose one workflow and ask what happens when a write’s outcome is unknown. Can the integration prove which record belongs to the operation? Who owns recovery? What may the customer be told while it is unresolved?
Incresco’s AI transformation and systems integration services are relevant to that design work. Contact Incresco to discuss a bounded workflow, its recovery decisions and the evidence needed before expanding autonomy. This is an invitation to discuss an implementation, not a claim of an existing packaged solution or delivered results.