A callback must identify the operation that produced it. A case ID alone is not enough when several runs or attempts can act on that case. If an old export result is attached to a new run, the agent can disclose the wrong scope of data or treat an unapproved earlier step as if the current run completed it.

Separate recording what happened from deciding where the result may be used. A cancelled run’s export can still succeed at the provider. The operation ledger should record that authenticated outcome under its original operation identity, even when no active model step is allowed to consume it. Cancellation blocks admission into the new run’s context. It does not require pretending the old external effect never completed.

Create the operation record before submission. Bind its business intent, initiating run, step, provider request identity, expected callback authority and authorization context. Multiple transport attempts may belong to one logical provider operation under an idempotency contract, so do not confuse the latest local attempt with a newly authorized business action. Where the provider exposes attempt-specific IDs, retain their mapping as well.

For a hypothetical example, R1 requests export E17 for January and is cancelled. R2 requests a different February scope. A callback for E17 must update E17’s evidence, not complete R2’s export. The current run may later learn that the January export exists through an explicit authorized reconciliation read. That new observation must remain distinguishable from its own completed tool step.

Verify callback authenticity before using its IDs. Then match the durable operation, validate the event type and status under the provider contract, and conditionally apply the observation. Duplicate event IDs or repeated identical terminal status should not create another downstream action. Conflicting terminal observations require provider-status reconciliation or another defined ordering rule, rather than blindly accepting the latest arrival. An unguessable operation ID helps routing, but is not a substitute for authenticating the sender.

Result admission needs a separate gate. Check that the receiving run and step still expect this operation and that the relevant intent/context revision remains eligible. A callback can be valid evidence about R1 while being invalid input to R2. Use the operation record’s immutable binding instead of looking up whichever run currently owns the case. The Temporal activity-execution documentation illustrates why asynchronous completion has a tracked execution identity. Application-specific permissions and result-use rules still need implementation.

Register before launching where possible. If a callback can arrive before the submission response provides its provider ID, persist an authenticated inbox event and correlate it through the API’s client reference or later response. An in-memory waiter can disappear on restart, and a missing waiter does not make an otherwise valid provider outcome irrelevant. Retain unmatched events for a bounded reconciliation process without attaching them by guesswork.

If the old operation exported a file, sent an email or charged money, recording its late result begins effect recovery. It may require revoking a file, sending a correction or requesting a separately authorized reversal. Ignoring the callback cannot undo the effect. Keep this recovery attached to the original operation so a new run cannot accidentally create a duplicate while trying to repair it.

Test cancellation, restart with changed scope, duplicate callbacks, forged callbacks, callbacks before registration and two local attempts for the same provider operation. Assert both ledger truth and context admission. Provider handoff after a tool result concerns which context can survive a model-provider failure. An intent change during a submitted tool call concerns replacing the plan. Here the arrival path must preserve the old operation’s outcome while fencing its use by a newer run.