Skip to content

Commit aeef656

Browse files
authored
docs: fix task doc (#848)
Fixes #836
1 parent 4916771 commit aeef656

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

docs/topics/life-of-a-task.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,47 @@
33
When a message is sent to an agent, it can choose to reply with either:
44

55
- 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`.
77

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`).
99

1010
## Context
1111

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.
1313

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.
1515

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.
1717

1818
## Agent: Message or a Task
1919

2020
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`.
2121

2222
So conceptually there can be three levels of agents:
2323

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.
2727

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.
2929

3030
## Task Refinements & Follow-ups
3131

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`.
3333

3434
Once a task has reached a terminal state (`completed`, `cancelled`, `rejected` or `failed`), it can't be restarted. There are some benefits to this:
3535

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.
3840
- 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.
4143

4244
### Parallel Follow-ups
4345

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.
4547

4648
For example:
4749

@@ -56,22 +58,24 @@ Task 4: Based on Task 2, add a spa reservation to the hotel booking.
5658

5759
### Referencing Previous Artifacts
5860

59-
The agent is responsible for inferring the relevant artifact from the referenced task or from the contextID. The serving agent is 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.
6062

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.
6264

6365
This approach allows for the client implementation to be simple.
6466

6567
### Tracking Artifact Mutation
6668

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.
6870

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.
7072

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.
7274

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.
7579

7680
### Example Follow-up
7781

0 commit comments

Comments
 (0)