AlgoViz

Delegating work across agents with A2A

medium 6 min

A tool call usually invokes a capability under the calling application’s control.

Video lesson · Chapter 1 of 4

A cancellation crosses a finished quote

0:00 / 3:21

Theory

Read or listen first. About 2 min.

What it is

A tool call usually invokes a capability under the calling application’s control. A delegated task may cross into an independently operated agent that owns its workflow, status and artifacts. A2A describes agent discovery through an Agent Card and operations for messages and tasks. The sender must preserve user intent and authority across this new boundary.

Why it exists

Establish which principal is acting, which resources can be read and what the remote agent may change. Store the remote task handle with the local business identity. Progress messages help the UI but are distinct from a verified terminal state. A cancellation request can race with completion. Reconcile the downstream record before claiming that nothing happened.

Cancel a supplier task after partial fulfilment

Delegation record → Remote task (scoped message). Remote task → Artifact store (store artifact). Delegation record → Remote task (cancel request). Remote task → Reconciler (terminal status)
Delegation record → Remote task (scoped message). Remote task → Artifact store (store artifact). Delegation record → Remote task (cancel request). Remote task → Reconciler (terminal status)

Inside this chapter

Chapter sources
Agent Cards and declared capabilities
A card describes interfaces, skills and security requirements. Use it to choose a compatible peer and transport. Independently authenticate the peer and authorize the actual delegation. A description of a capability grants no user authority.

An Agent Card is a published description of an agent: its endpoint, the skills it offers, the interfaces it speaks and the authentication it expects. It is advertising, so use it to choose a compatible peer, then authenticate the peer independently and decide what to delegate from the user's actual permissions. A card listing a capability never widens what the user authorised.

Example. A supplier advertises shipment scheduling. The user’s grant allows a quote only, so the task must not authorize an actual shipment.

Another example. A travel agent discovers a hotel agent whose card lists booking and cancellation. The user has only asked for prices, so the delegated task asks for a quote and carries no booking authority.

From a discovered card to a scoped delegation

The card says what the peer can do. Only the user's grant says what this task may do.
Task state and artifacts
Persist task identity, context and returned artifacts under the originating tenant. Associate streaming updates with the correct task, recover state after disconnection, and authorize artifact retrieval independently.

A delegated task has its own identity and lifecycle on the remote side. Store the remote task ID next to your own business ID and tenant so updates can be matched to the right request. Streaming events are convenient but can be missed during a disconnect, so on reconnect fetch the task state rather than redisplaying a cached "working". Fetch artifacts with their own authorisation check, because a task ID is not a licence to read its outputs.

Example. After reconnecting, read the supplier task’s state before displaying a cached “working” event as current.

A remote task's lifecycle

Simplified. After a disconnect, read the task's current state before trusting the last streamed event.
Cancellation and remote ownership
Treat cancellation as a request handled by the remote executor. Reconcile a terminal completion, cancellation or failure against committed business effects. Surface partial results and obtain fresh consent for compensating actions when required.

Sending cancel is a request, not a command, because the remote agent owns execution and may already have finished. Always reconcile the terminal state the remote side reports with any committed business effects. If work completed, surface the artifact honestly; if undoing it needs a compensating action, that is a new decision that may need fresh consent.

Example. A supplier produced a quote just before cancellation. Preserve that artifact with its actual state instead of telling the user no work was done.

Cancel races with completion

The supplier owns the task, so it decides which state won. The buyer reports what was recorded.
Tool call vs delegated task
A tool call runs an operation under the caller's control and returns a result in one exchange. A delegated task hands a goal to an independently operated agent that keeps its own workflow, state and artifacts, often over a longer time.

The difference is ownership. With a tool, your code decides when to retry, what counts as done and what to log. With a delegated task, those decisions live with someone else, so you track a remote handle, poll or subscribe for progress and reconcile its terminal state. Picking the wrong model leads to bugs such as retrying a delegated task that is still running and creating a duplicate.

Example. Calling get_rate(postcode) is a tool call. Asking a supplier agent to produce a quote that may need clarifying questions is a delegated task.

Tool call

  • Caller controls execution and retries
  • One request, one result
  • Schema defined by the caller's catalogue
  • Errors returned directly

Delegated task

  • Remote agent controls its own workflow
  • Long-lived task with states and artifacts
  • Capabilities discovered from its card
  • May ask questions, stream progress or be cancelled
Delegated authority
When one agent acts for a user towards another agent, the authority it presents must be scoped to what the user granted for this task, verifiable by the receiver and no broader than needed.

The risk across agent boundaries is that the delegating agent passes on more power than the user gave, for example its own service credentials. Prefer short-lived credentials scoped to the user, the action and the resource, and have the receiving agent verify them rather than trusting what the request says about itself. Log which principal each remote action ran as, so an audit can tell the user's actions from the agent's.

Example. The buyer agent presents a credential limited to requesting quotes for this user. The supplier rejects a scheduling request made with it.

Authority narrows at every hop
  1. 1User grantquotes only, this order
  2. 2Buyer agentrequests a scoped credential
  3. 3Supplier verifieschecks issuer, scope, expiry
  4. 4Quote allowedwithin scope
  5. 5Schedule refusedoutside scope

The receiver checks the credential itself. A claim in the message text carries no authority.

How it works

Step through the idea, or press Play.

Step 1 of 4

Delegation record. Request a quote only

Understand it

Worked example

Cancel a supplier task after partial fulfilment

  1. 1

    Request a quote only

    The buyer creates a scoped task with no authority to reserve or ship goods.

  2. 2

    Track supplier work independently

    Record the task identifier and authorization. The buyer can check progress after a connection loss.

  3. 3

    A quote commits during cancellation

    Resolve which state actually won. Keep access controls on the resulting quote.

  4. 4

    Present the terminal outcome

    Show the recorded quote and tell the buyer whether further action is required.

Follow the handoffs

Establish which principal is acting, which resources can be read and what the remote agent may change. Store the remote task handle with the local business identity. Progress messages help the UI but are distinct from a verified terminal state. A cancellation request can race with completion. Reconcile the downstream record before claiming that nothing happened.

The cancellation race, step by step

TimeBuyer agent seesSupplier record
t1task created, quote onlySubmitted
t2workingWorking
t3(nothing yet)quote Q-12 committed
t4sends cancelCompleted with Q-12
t5reads task stateCompleted with Q-12
Illustrative timeline. The buyer's cancel arrived after the supplier had already finished.

Reconcile before showing an outcome

Summary

The whole topic in one minute.

Sending a cancellation message is not evidence that the remote service cancelled before committing.

Establish which principal is acting, which resources can be read and what the remote agent may change. Store the remote task handle with the local business identity. Progress messages help the UI but are distinct from a verified terminal state. A cancellation request can race with completion. Reconcile the downstream record before claiming that nothing happened.

Sources