AI

AgentOps: validate parallel tool execution before production actions collide

A production runbook for classifying independent agent tool calls, detecting resource conflicts, enforcing ordering and validating rollback before enabling parallel execution.

04 Nov 2026 aiagentopsagentsmcpmicrosoft-foundrytoolsconcurrencyidempotencyobservabilitykqlevaluationguardrailsautomationrunbookrollbackproduction

An operations agent diagnoses a degraded Azure service. To shorten response time, its runtime starts several tool calls together: read the active deployment, query recent errors, inspect capacity and prepare a scale change. The first three are observations. The fourth assumes that the deployment and capacity snapshots still describe the target when the write begins.

The optimization works until two calls share a resource or one consumes evidence produced by another. A scale request can race with a rollback, two incident updates can overwrite each other, or a late read can validate a state that no longer exists. Each tool can be correct in isolation while the combined execution is unsafe.

This runbook uses a Microsoft Foundry operations agent connected to bounded MCP tools as the running case. The controls are runtime-neutral: classify dependencies, bind calls to one intent and resource version, serialize conflicting actions, then decide whether to promote parallel reads, keep a sequential path or roll back the orchestration change.

Freeze the execution graph, not only the transcript

Return write-capable tools to mandatory approval or draft-only mode. Preserve the agent release, model, instructions, tool catalog, orchestration policy and one complete trace. A transcript shows the order in which messages appeared; it may not show when calls started, overlapped or reached their backends.

yaml 01-parallel-tool-incident.yml
incident: INC-AI-948
agent_release: ops-agent-2026-11-04.2
orchestrator_policy: parallel-tools-v3
intent_id: intent-7d42
target_resource: /subscriptions/.../resourceGroups/rg-prod/providers/.../orders-api
containment:
write_tools: approval_always
parallel_read_tools: canary_only
maximum_in_flight_per_intent: 1
evidence:
- trace_and_tool_call_ids
- start_and_end_times
- tool_catalog_digest
- arguments_digest
- target_resource_version
- backend_operation_id
- approval_and_result

Keep backend identifiers as well as agent call identifiers. A runtime may retry a timed-out call under a new call ID while the first backend operation is still active.

Classify calls by dependency and effect

Parallel execution is safe only when calls are independent for the current intent. A readOnlyHint or a tool name beginning with get is not enough. A read can consume scarce capacity, create an audit record, refresh a cache or return state that another call uses as a precondition.

Build an execution contract for the effective catalog exposed to the agent.

yaml 02-tool-concurrency-contract.yml
tools:
- name: logs.query_recent_errors
  effect: read
  resource_key: workspace
  parallel_group: evidence
  output_freshness_seconds: 60

- name: deployment.get_active
  effect: read
  resource_key: application
  returns_version: true
  parallel_group: evidence

- name: capacity.get_current
  effect: read
  resource_key: application
  returns_version: true
  parallel_group: evidence

- name: capacity.prepare_scale
  effect: draft
  resource_key: application
  requires:
    - deployment.get_active
    - capacity.get_current
  parallel_group: none

- name: capacity.execute_scale
  effect: write
  resource_key: application
  requires_approval: true
  requires_version_match: true
  idempotency_key: required
  parallel_group: none

Use a stable resource_key that represents the real conflict boundary. Two calls with different tool names still conflict when both change the same App Service, route table, deployment slot or incident record. Conversely, two reads against different resources may be independent even if they use the same tool.

Make the dependency graph explicit

For each intent, construct a directed graph before dispatch. Independent evidence reads may share a wave. A call that derives a plan must wait for every required read. Approval must bind to the completed plan, and the write must recheck the resource version immediately before execution.

text 03-execution-graph.txt
WAVE 1 - MAY RUN IN PARALLEL
deployment.get_active ----+
                          +--> capacity.prepare_scale
capacity.get_current -----+             |
logs.query_recent_errors ----------------+--> approval(plan_digest)
                                               |
                                               v
                                    capacity.execute_scale

SERIALIZATION RULES
One active write lease per resource_key
A write starts only after required reads completed successfully
Approval references intent_id, plan_digest and resource_version
Version mismatch invalidates the plan and approval
Cancellation prevents undispatched calls and marks late results unusable

Do not let completion order rewrite the plan. If the logs query returns last, the orchestrator must either include it in the declared gate or treat it as optional evidence. Hidden “first result wins” behavior makes identical requests produce different actions under ordinary latency variation.

Reconstruct overlap from traces

Record one event per attempt with monotonic timing where possible. Wall-clock timestamps are still required for cross-system correlation, but duration and overlap should not depend on clocks being perfectly synchronized.

kusto 04-find-conflicting-tool-overlap.kql
let Start = ago(2h);
let Calls = AgentToolCallEvents
| where TimeGenerated >= Start
| where isnotempty(IntentId) and isnotempty(ResourceKey)
| project IntentId, ToolCallId, Attempt, ToolName, Effect,
        ResourceKey, StartedAt, CompletedAt, Result,
        ResourceVersion, BackendOperationId;
Calls
| join kind=inner Calls on IntentId, ResourceKey
| where ToolCallId < ToolCallId1
| where StartedAt < CompletedAt1 and StartedAt1 < CompletedAt
| extend Conflict = Effect == "write" or Effect1 == "write"
| where Conflict
| project IntentId, ResourceKey,
        FirstTool=ToolName, FirstEffect=Effect,
        SecondTool=ToolName1, SecondEffect=Effect1,
        OverlapStart=max_of(StartedAt, StartedAt1),
        OverlapEnd=min_of(CompletedAt, CompletedAt1),
        BackendOperationId, BackendOperationId1
| order by OverlapStart desc

Adapt table and column names to the telemetry pipeline. The operational signal is not simply “more than one call.” It is temporal overlap on the same conflict key, especially when at least one call can write or when one output is a declared prerequisite for the other.

Also compare intents with backend operations. More than one backend write for one approved intent exposes retry or concurrency amplification even when the agent trace contains a single visible action.

Enforce concurrency below the prompt

Instructions can ask the model to order tools, but the invariant belongs in orchestration and backend authorization. Use three layers.

  1. The planner emits dependencies and a resource conflict key.
  2. The orchestrator dispatches only ready calls and holds a short write lease per conflict key.
  3. The backend requires idempotency and optimistic concurrency for mutations.
json 05-write-envelope.json
{
"intentId": "intent-7d42",
"toolCallId": "call-scale-03",
"resourceKey": "app:orders-api:prod",
"operation": "scale",
"expectedResourceVersion": "rev-1842",
"planDigest": "sha256:<reviewed-plan>",
"approvalId": "apr-20491",
"approvalExpiresAt": "2026-11-04T09:20:00Z",
"idempotencyKey": "intent-7d42:scale:rev-1842"
}

The backend should reject a stale version, expired approval, reused idempotency key with different arguments, or conflicting active lease. A lock without a version check merely serializes two outdated decisions. A version check without idempotency can still repeat the same accepted write after a timeout.

Test adversarial schedules, not one happy trace

Deterministic sequential tests miss concurrency defects. Run the same cases with injected latency so every completion order occurs. The expected result must remain stable.

yaml 06-parallel-execution-evaluation.yml
cases:
- name: independent_reads_finish_in_any_order
  tools: [deployment.get_active, logs.query_recent_errors, capacity.get_current]
  expect: one_identical_plan_digest

- name: stale_read_before_write
  inject: resource_changes_after_plan
  expect: write_rejected_version_mismatch

- name: two_writes_same_resource
  tools: [capacity.execute_scale, deployment.execute_rollback]
  expect: one_dispatched_other_blocked

- name: timeout_with_late_completion
  inject: first_write_returns_after_client_timeout
  expect: one_backend_operation

- name: cancellation_during_parallel_wave
  inject: user_cancels_before_plan
  expect: no_write_and_late_results_discarded

promotion_gate:
conflicting_write_overlap: 0
duplicate_backend_writes: 0
stale_version_writes: 0
plan_digest_stable_across_schedules: true
trace_completeness: required

Include negative canaries: a second write on the same resource must be blocked, a write on a different resource may proceed, and an old approval must not authorize a recomputed plan. Measure latency after correctness. Saving seconds is not a useful outcome if the resulting action cannot be reconstructed.

Promote the smallest parallel surface

Start with read-only calls whose outputs are independent and whose side effects are understood. Keep plan construction, approvals and writes sequential. Expand only when trace evidence shows stable plans across completion orders and the backend rejects stale or duplicate mutations.

Rollback is an orchestration change: restore the previous policy or release, set the maximum in-flight calls per intent to one, invalidate pending plans and approvals, and wait for already dispatched operations to reach a known terminal state. Do not assume that disabling the agent cancels calls already accepted by a backend.

The final decision has three outcomes:

  1. Promote parallel reads when independence, isolation and trace completeness are proven.
  2. Hold a mixed policy when evidence collection is parallel but planning and writes remain serialized.
  3. Roll back parallel dispatch when conflicts, unstable plans or duplicate backend operations cannot be bounded.

Conclusion

Parallel tool execution is not a model setting to enable globally. It is a scheduling policy over dependencies, resource boundaries and effects. The useful unit of control is the intent plus the resource version, not the conversation alone.

When the execution graph is explicit, independent reads can reduce latency without making actions opaque. When a call depends on fresh evidence or can change production, serialize it, bind approval to the exact plan and require the backend to reject stale or duplicate writes. That leaves a clear promotion gate and a rollback that operators can actually execute.