# AX-SYS-35: Group related tasks under one context ID

> Memory and state · intermediate · AX-SYS-35

When several tasks belong to the same piece of work, give them a shared context ID the agent can send back, so a follow-up starts with the history of the case instead of from nothing.

## Why

A support case is rarely one call. The customer asks for a refund, then for the shipping fee, then why the bank statement still shows the charge. If each request starts a new, unrelated task, the agent has to restate everything, the server cannot tell a follow-up from a fresh request, and a second agent that picks up the case sees fragments. A2A builds the grouping into the protocol. A `contextId` logically groups related tasks and messages to give continuity across a series of interactions. A client may send it without a `taskId` to start a new task inside an existing context, and an agent that cannot accept a client-provided `contextId` must reject the request rather than quietly mint a new one. OpenAI's API draws the same line between a single call and the thread around it: a conversation object can be reused across sessions, devices or jobs, and while response objects are kept for 30 days by default, conversation items are not subject to that TTL. The context is not a key to the data. A2A requires results to be scoped to what the caller is authorized to see even when no `contextId` is given, so the ID groups work without granting access to it. [AX-SYS-16](ax-sys-16-persist-state-across-workflows.mdx) keeps one task resumable; this principle links the separate tasks of one case.

## Do

Return a context ID with the first task, accept it on later requests, let agents list tasks by context, and reject a context ID you cannot honor.

## Don't

Treat every follow-up as a new conversation, or silently replace the context ID an agent sent with a new one.

## Artifact

```json
{
  "message": {
    "role": "ROLE_USER",
    "messageId": "msg_552",
    "contextId": "ctx_refund_ord123",
    "referenceTaskIds": ["task_refund_01"],
    "parts": [{ "text": "Also refund the $6.90 shipping fee on the same order." }]
  }
}
```

`GET /tasks?contextId=ctx_refund_ord123` then returns both tasks, so any agent that picks up the case sees the full history, within its own permissions.

## Citations

1. [A2A Protocol Specification (Context Identifier Semantics)](https://a2a-protocol.org/latest/specification/): A contextId logically groups multiple related Task and Message objects, providing continuity across a series of interactions; clients MAY use contextId without taskId to start a new task within an existing conversation context; an agent that cannot accept a client-provided contextId MUST reject the request with an error and MUST NOT generate a new contextId; even when no contextId is given, results MUST be scoped to the caller's authorized access boundaries
2. [OpenAI API Docs: Conversation state](https://developers.openai.com/api/docs/guides/conversation-state): After creating a conversation object, you can keep using it across sessions, devices, or jobs; response objects are saved for 30 days by default, while conversation objects and the items in them are not subject to the 30 day TTL

---
Source: Agent Experience Principles (axprinciples.com)