You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/life-of-a-task.md
+26-22Lines changed: 26 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,45 +3,47 @@
3
3
When a message is sent to an agent, it can choose to reply with either:
4
4
5
5
- A stateless `Message`.
6
-
- A stateful `Task`and zero or more `TaskStatusUpdateEvent` or `TaskArtifactUpdateEvent`.
6
+
- A stateful `Task`followed by zero or more `TaskStatusUpdateEvent` or `TaskArtifactUpdateEvent`.
7
7
8
-
If the response is a `Message`, the interaction is completed. On the other hand, A `Task`will keep getting updated until it is in a interrupted state (`input-required` or `auth-required`) or a terminal state (`completed`, `cancelled`, `rejected` or `failed`).
8
+
If the response is a `Message`, the interaction is completed. On the other hand, if the response is a `Task`, then the task will be processed by the agent, until it is in a interrupted state (`input-required` or `auth-required`) or a terminal state (`completed`, `cancelled`, `rejected` or `failed`).
9
9
10
10
## Context
11
11
12
-
A contextId logically composes many Tasks and independent Messages. Agent implementor can manage the llm context based on these interactions, utilizing the `contextId`.
12
+
A `contextId` logically composes many `Task` objects and independent `Message` objects. If the A2A agent uses an LLM internally, it can utilize the `contextId` to manage the LLM context.
13
13
14
-
For the first time a message is sent, agent replies back with a contextId. If the agent responded with a task, then it will also have a taskId. Clients can send subsequent messages and attach the same contextID to indicate to the agent that they are continuing their previous interaction within the same context. Client also optionally attach the taskID to indicate that the message is in continuation of that specific task.
14
+
For the first time a message is sent, agent replies back with a `contextId`. If the agent responded with a task, then it will also have a `taskId`. Clients can send subsequent messages and attach the same `contextId` to indicate to the agent, that they are continuing their previous interaction within the same context. Client can optionally attach the `taskId` to a subsequent message to indicate that the message is in continuation of that specific task.
15
15
16
-
ContextId allows collaboration over a goal or share one session across multiple tasks.
16
+
`contextId` allows collaboration over a goal or share a single contextual session across multiple tasks.
17
17
18
18
## Agent: Message or a Task
19
19
20
20
Messages can be used for trivial interactions which do not require long-running processing or collaboration. An agent can use messages to negotiate the acceptance of a task. Once an agent maps the intent of an incoming message to a supported capability, it can reply back with a `Task`.
21
21
22
22
So conceptually there can be three levels of agents:
23
23
24
-
1.Always responds with Messages only. Doesn't do complex state management, no long running execution and uses contextID to tie messages together. Agent most probably directly wraps around an LLM invocation and simple tools.
25
-
2. Generates a task, does more substantial work that can be tracked and runs over extended life time.
26
-
3. Generates messages and tasks. Uses messages to negotiate agent capability and scope of work for a task. Then sends task to track its execution and collaborate over task states like more input-needed, error handling, etc.
24
+
1.An agent which always responds with `Message` objects only. Doesn't do complex state management, no long running execution and uses contextID to tie messages together. Agent most probably directly wraps around an LLM invocation and simple tools.
25
+
2. Generates a `Task`, does more substantial work that can be tracked and runs over extended life time.
26
+
3. Generates both `Message`and `Task` objects. Uses messages to negotiate agent capability and scope of work for a task. Then sends `Task` object to track its execution and collaborate over task states like more input-needed, error handling, etc.
27
27
28
-
An agent can choose to always reply back with task objects and model simple responses as tasks in `completed` state.
28
+
An agent can choose to always reply back with `Task` objects and model simple responses as tasks in `completed` state.
29
29
30
30
## Task Refinements & Follow-ups
31
31
32
-
Client may want to follow up with new asks based on the results of a task, refine upon the task results. This can be modeled by starting another interaction using the same contextID as the original task. Client can further hint the agent by providing the reference to the original task using `referenceTaskIds` in `Message` object. Agent would then either create a new `Task` or a `Message`.
32
+
Clients may want to follow up with new asks based on the results of a task, and/or refine upon the task results. This can be modeled by starting another interaction using the same `contextId` as the original task. Clients can further hint the agent by providing the reference to the original task using `referenceTaskIds` in `Message` object. Agent would then respond with either a new `Task` or a `Message`.
33
33
34
34
Once a task has reached a terminal state (`completed`, `cancelled`, `rejected` or `failed`), it can't be restarted. There are some benefits to this:
35
35
36
-
-**Task Immutability**: Clients can reliably reference tasks and their associated state, artifacts, and messages. This provides a clean mapping of inputs to outputs. Useful for mapping client planner nodes to task execution.
37
-
-**Clear Unit of Work**: Every new request, refinement, or follow-up becomes a distinct task, simplifying bookkeeping and allowing for granular tracking of an agent's work.
36
+
-**Task Immutability**: Clients can reliably reference tasks and their associated state, artifacts, and messages.
37
+
- This provides a clean mapping of inputs to outputs.
38
+
- Useful for mapping client orchestrator to task execution.
39
+
-**Clear Unit of Work**: Every new request, refinement, or a follow-up becomes a distinct task, simplifying bookkeeping and allowing for granular tracking of an agent's work.
38
40
- Each artifact can be traced to a unit task.
39
-
- This unit of work can be referenced much more granularly by parent agents or other systems like agent optimizers. Instead of restartable tasks, where all the subsequent refinements are clubbed together and would need to resort to some kind of message index range.
40
-
-**Easier Implementation**: Agent developers follow a simple rule: always create a new task for a request referring a task in terminal state.
41
+
- This unit of work can be referenced much more granularly by parent agents or other systems like agent optimizers. In case of restartable tasks, all the subsequent refinements are combined, and any reference to an interaction would need to resort to some kind of message index range.
42
+
-**Easier Implementation**: No ambiguity for agent developers, whether to create a new task or restart an existing task. Once a task is in terminal state, any related subsequent interaction would need to be within a new task.
41
43
42
44
### Parallel Follow-ups
43
45
44
-
Parallel work is supported by having the agent create distinct, parallel tasks for each follow-up message sent within the same contextId. This allows clients to track individual sub-tasks and create new dependent tasks as soon as a prerequisite task is complete.
46
+
Parallel work is supported by having agents create distinct, parallel tasks for each follow-up message sent within the same contextId. This allows clients to track individual tasks and create new dependent tasks as soon as a prerequisite task is complete.
45
47
46
48
For example:
47
49
@@ -56,22 +58,24 @@ Task 4: Based on Task 2, add a spa reservation to the hotel booking.
56
58
57
59
### Referencing Previous Artifacts
58
60
59
-
The agent is responsible for inferring the relevant artifact from the referenced task or from the contextID. The serving agentis best suited to resolve ambiguity or identify missing information.
61
+
The serving agent is responsible for inferring the relevant artifact from the referenced task or from the `contextId`. The serving agent, as the domain expert, is best suited to resolve ambiguity or identify missing information because they are the ones who generated the artifacts.
60
62
61
-
If there is ambiguity (e.g., multiple artifacts could fit the request), the agent will ask the client for clarification by returning an input-required state. The client can then specify the artifact in its response. Client can optionally populate artifact reference {artifactId, taskId} in part metadata. This allows for linkage between inputs for follow-up tasks and previous generated artifacts.
63
+
If there is ambiguity (e.g., multiple artifacts could fit the request), the agent will ask the client for clarification by returning an input-required state. The client can then specify the artifact in its response. Client can optionally populate artifact reference {artifactId, taskId} in part metadata. This allows for linkage between inputs for follow-up tasks and previously generated artifacts.
62
64
63
65
This approach allows for the client implementation to be simple.
64
66
65
67
### Tracking Artifact Mutation
66
68
67
-
A follow up or refinement can result in an older artifact being modified and newer artifacts being generated. It would be good to know this linkage and maybe track all mutations of the artifact to make sure only the latest copy is used for future context. Something like a linked list, with a head as the latest.
69
+
A follow up or refinement can result in an older artifact being modified and newer artifacts being generated. It would be good to know this linkage and maybe track all mutations of the artifact to make sure only the latest copy is used for future context. Something like a linked list, with the head as the latest version of the task result.
68
70
69
-
But the client is best suited, as well as is the real decider of what it considers as a result. And in fact can reject the mutation as well. Hence, the serving agent should not own this linkage and hence does not need to be part of A2A protocol spec. The serving agent should maintain the same artifact-name when generating a refinement on the original artifact.
71
+
But the client is best suited, as well as is the real judge of what it considers as an acceptable result. And in fact can reject the mutation as well. Hence, the serving agent should not own this linkage and hence this linkage does not need to be part of A2A protocol spec. Clients can maintain the linkage on their end and show the latest version to the user.
70
72
71
-
For follow-up or refinement tasks, the client is best suited to refer to the "latest" or what it considers to be the intended artifact to be refined upon. If artifact reference is not explicitly specified, the serving agent can:
73
+
To help with the tracking, the serving agent should maintain the same artifact-name when generating a refinement on the original artifact.
72
74
73
-
Use context to figure out the latest artifact.
74
-
Or in case of ambiguity or context not supported, agent can use "input-required".
75
+
For follow-up or refinement tasks, the client is best suited to refer to the "latest" or what it considers to be the intended artifact to be refined upon. If the artifact reference is not explicitly specified, the serving agent can:
76
+
77
+
- Use context to figure out the latest artifact.
78
+
- Or in case of ambiguity or context not supported, agent can use `input-required` task state.
0 commit comments