ADR 0055 — The agent assigns the A2A context: a thread's first message names none, and the binding adopts what the agent answers ​
- Status: accepted (2026-10-07), on the owner's approval of the same day. Refines ADR 0021 (which said the thread's id is the context of every message) and ADR 0029 (a fork's context). Built and proven on mocks and unit tests, including agents that refuse a context they did not create; the kagent scenarios that prove it against kagent itself (
dev/kagent-e2e.sh) have not run yet, CI is their first run. Amended (2026-11-18, ADR 0072, proposed): a child thread's context is adopted from the parent task'sopenedevent, or from the answer to a person'sstart, not from a first answer of its own.
Context ​
ADR 0021 made the thread's id the contextId of every message of the thread, the first included, and the verifier's and an asked agent's contexts derived names (<thread>-verify-<n>-<m>, <thread>-ask-<agent>). That is a client inventing the context. The protocol says the other way round: verified 2026-10-07 (https://a2a-protocol.org/latest/topics/life-of-a-task/, "ContextId Generation"): "When a client sends a message for the first time, the agent responds with a new contextId." Most agents tolerate an invented one (adam-rs does: it takes the context a message names and makes one when it names none, crates/adam-a2a-runtime/src/backend.rs, verified 2026-10-07 at adam-rs origin/main, and at the pinned 6478fbc). kagent does not: its resolveSend loads the Session of a message's contextId and answers ErrUnauthorized when there is none; only a message with no contextId and no taskId creates a conversation (verified 2026-10-07 by reading kagent 1.x's source, go/core/internal/service/session/interactions.go; not run). So a thread whose agent is kagent could never get its first message through. The orchestrator also never adopted a context an agent returned.
Decision ​
- The first message to an agent in a conversation names no
contextId.SendRequest.context_idisOption<String>; both adapters (A2A and the in-process adam) put it in the message only when it isSome. A message that continues a task still names itstaskId. - The binding adopts the agent's context, once. The thread's binding (
a2a_bindings, the job ledger that already holds the task, its state and the revision, written in the commit that causes it or bymark_sent) getscontext_idasOption:Nonefrom creation;BindingUpdate.context_idcarries thecontextIdof the first envelope the dispatcher reads (the one that records the message as sent) and of every envelope after, and the store sets it only while it isNone(COALESCE(context_id, $new); the in-memory store the same; an empty string is none). The first context stands: a poll that names another one changes nothing. Every later message of the thread, a follow-up, a rework, an answer, a steer, a new job, is sent in it. A fork is a thread: its binding starts empty and adopts its own context with its agent's first answer. - Where it lives. Not an event: the log is the conversation, and a context is the A2A side of it, like the task id and the state that the binding keeps beside it (ADR 0001 counts the job ledger as persistent state). The pure core never sees it; the dispatcher reads it from the binding for every send, so a restarted or second process sends what the first one learned.
Storegains no method:NewThreadRecord.context_idandAgentBinding.context_idbecomeOption<String>andBindingUpdategains a field (an implementer ofThreadStoremust apply it with the once-only rule; the conformance casethe_binding_adopts_the_agents_context_oncesays how). Migration0019_binding_context_assigned.sqldropsNOT NULLfrom the column. - A thread that began before this ADR keeps its context. Its binding holds its own id, which is not
None, so it is sent as before and never replaced. Roll the build out to every replica before any of them creates a thread: an older build fails to read a binding whose context isNULL. - The verifier names no context. A verification is one message in a conversation of its own, and nothing is ever sent into it again, so there is nothing to record: the request names none and the verifier starts one.
orch_core::verifier_contextis no longer sent (it stays, with its tests, as the name an older build used). - An asked agent's context is kept on the ask ledger, per job. The first ask of an agent in a job names no context; the dispatcher tells the core the context the agent answered in with the task (
Input::AskSent.context_id, recorded once on theAsk), and the next ask of the same agent in the job is written with it (Command::Ask.context,OutboxPayload::Ask.context) and goes on in it. A later job starts a new conversation with the agent: the ledger is forgotten with the job, and the context<thread>-ask-<agent>(ask_context), which used to survive jobs, no longer names a new ask's. A row written by an older build that continues or refers to a task, and so names no context, is sent inask_context, where its earlier tasks live. - The lookup after a crash works without a context.
AgentClient::find_task_by_messagetakesOption<&str>: a message sent with no context is looked up by its id alone (ListTasksunfiltered, bounded by the same page limit; the in-process adam adapter derives the task id from a missing context, which is exactly what the runtime does). The mocks and the conformance suite say what an adapter must do. - No agent is asked to change. An agent that accepts a made-up context also accepts none, and answers with its own. The conformance case
a_message_with_no_context_starts_onesays it for every adapter and for the scripted agent.
sequenceDiagram
participant D as Dispatcher
participant S as Store (binding)
participant A as Agent (kagent, adam, ...)
D->>S: get_binding: context_id = none
D->>A: SendStreamingMessage (no contextId, messageId = row id)
A-->>D: task T1, contextId C (assigned by the agent)
D->>S: mark_sent(task T1, context C): C is stored, the first one stays
A-->>D: ... completed
Note over D,S: the person follows up, or a rework
D->>S: get_binding: context_id = C
D->>A: SendStreamingMessage (contextId C, referenceTaskIds [T1])
A-->>D: task T2, contextId CstateDiagram-v2
[*] --> Unassigned: a new thread, a fork
Unassigned --> Assigned: the first envelope that names a context
Unassigned --> Unassigned: an envelope that names none
Assigned --> Assigned: any later context is ignored
[*] --> Assigned: a thread that began before this ADR (its own id)Consequences ​
- A thread's agent can be kagent, and any agent that creates its own conversations. The scenario against kagent 0.10 and 1.x is the proof; until CI runs it, kagent is proven only by reading its source.
- The binding's context is
nullin the thread export (binding.contextId,docs/api/chat-api.yaml) until the agent's first answer. - A send that reached the agent but whose first envelope was never read (the process died, the stream broke before the first event) leaves the binding without a context, and the retry sends the first message again with none. adam-rs derives the task's id from the message id, so the retry reaches the same task; another agent may start a second conversation and leave the first idle. The lookup by message id (decision 7) is what narrows it; it is best-effort, as it always was.
- The mock agents (
dev/wiremock/*) answer a request that names no context with one of their own, the message id (default=msgId), and echo one it is given; the scenario scripts that found a thread's requests by its context find them by the first message's words and then by that context. - The in-memory
ScriptedAgentand the test fake (orch-testsupport) can be made strict (reject_unknown_contexts,FakeAgentOptions::strict_contexts): they refuse a context they did not assign, as kagent does, so a test proves the orchestrator never names one it was not given.
Alternatives rejected ​
- Keep the thread id and tell kagent's operators to accept it. It is kagent's, not ours, and the protocol puts the context on the agent's side.
- An event field the core folds (
agent_context_assigned): the log would carry A2A bookkeeping no reader wants, and the core has no use for it; the binding is where the task id, the task state and the revision already are. - Rewriting a started thread's context to an agent-assigned one: there is nothing to rewrite to; the agent already knows the thread id as its context.
- Sending no context ever and relying on
taskId: a rework and a follow-up after the turn is over start a new task, and without the context the agent cannot say the new task belongs to the conversation.
Verified ​
- Verified 2026-10-07 (https://a2a-protocol.org/latest/topics/life-of-a-task/): the agent responds with a new
contextIdto a first message. - Verified 2026-10-07 (adam-rs
origin/main,crates/adam-a2a-runtime/src/backend.rs,ids.rs): a message without acontextIdgetsa2a::new_context_id(), the task istask_id_for(agent, subject, None, messageId), and a repeat of the same message finds the run it made;6478fbc, the revision this repository pins, has the same. - Verified 2026-10-07 by reading, not running (kagent 1.x, the owner's reading of
resolveSend): acontextIdthat is no Session of its own isErrUnauthorized; nocontextIdand notaskIdcreates a conversation. - Unverified: kagent 0.10's behaviour for the same (the scenario reads it).
Amendment: what the first run of the kagent 0.10 scenario found (2026-10-07) ​
- Against kagent 0.10.3 the first message went through with no context, kagent assigned one and the binding adopted it (observed in CI 2026-10-07, job
kagent-010); kagent 0.10 accepts acontextIdthe caller made up and answers in it, where 1.x refuses. This ADR's rule (name none, adopt the agent's) is right for both; only 1.x needs it. - The same run showed a different gap: the answer reached the orchestrator and was not recorded as the agent's message, because kagent gives it as an unnamed text artifact. That is the mapping's, fixed in ADR 0031, which records what kagent 0.10.3 streams, with the source lines.