Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(provider): a conversation belongs to ONE skill, for its whole life

0xken15106722434e13
diff --git a/provider/example-provider/src/server.spec.ts b/provider/example-provider/src/server.spec.ts
index 1869c3701..dd995047c 100644
--- a/provider/example-provider/src/server.spec.ts
+++ b/provider/example-provider/src/server.spec.ts
@@ -48,7 +48,13 @@ const resultLine = (failed = false): unknown => ({
function config(claudeBin: string): Config {
return {
- agents: [{ id: 'scratch', name: 'Scratch', description: 'test agent', cwd: AGENT_CWD }],
+ // Three, because the bug this file has to keep out only appears with more than one: a provider
+ // that cannot tell which skill a turn belongs to files every conversation under the first.
+ agents: [
+ { id: 'scratch', name: 'Scratch', description: 'test agent', cwd: AGENT_CWD },
+ { id: 'agent-2', name: 'Second', description: 'second agent', cwd: AGENT_CWD },
+ { id: 'agent-3', name: 'Third', description: 'third agent', cwd: AGENT_CWD },
+ ],
workspaceRoot: ROOT,
agentsFile: join(ROOT, 'agents.json'),
claudeBin,
@@ -94,7 +100,7 @@ async function rpc<T = Record<string, unknown>>(port: number, method: string, pa
}
/** Run a turn and collect every SSE event, in order. */
-async function runTurn(port: number, text: string, contextId?: string): Promise<SseEvent[]> {
+async function runTurn(port: number, text: string, opts: { contextId?: string; agentId?: string } = {}): Promise<SseEvent[]> {
const res = await fetch(`http://127.0.0.1:${port}/`, {
method: 'POST',
headers: { 'content-type': 'application/json', 'x-api-key': 'test-key' },
@@ -102,7 +108,16 @@ async function runTurn(port: number, text: string, contextId?: string): Promise<
jsonrpc: '2.0',
id: 1,
method: 'SendStreamingMessage',
- params: { message: { role: 'ROLE_USER', messageId: 'm1', parts: [{ text }], ...(contextId ? { contextId } : {}) } },
+ params: {
+ message: {
+ role: 'ROLE_USER',
+ messageId: 'm1',
+ parts: [{ text }],
+ ...(opts.contextId ? { contextId: opts.contextId } : {}),
+ // HP-107 — the skill selector A2A has no field for.
+ ...(opts.agentId ? { metadata: { 'autonomous.ai/agentId': opts.agentId } } : {}),
+ },
+ },
}),
})
const raw = await res.text()
@@ -184,6 +199,50 @@ describe('SendStreamingMessage — the recap rides the stream (HP-212)', () => {
})
})
+describe('which skill a turn belongs to (HP-107 / HP-204)', () => {
+ interface WireTask { id: string; contextId?: string; metadata?: { agentId?: string } }
+
+ it('files the turn under the skill the client named, not the first one', async () => {
+ // The bug: with no selector the provider falls back to agents[0], so EVERY conversation on a
+ // multi-skill provider is attributed to the first skill — and the client, whose session list is
+ // scoped to one agent, shows the other agents as empty however much the user talked to them.
+ const bin = fakeClaude('claude-agent2.sh', [textLine('Done for the second agent.'), resultLine()])
+ const tasks = await withServer(bin, async (port) => {
+ await runTurn(port, 'hello agent two', { agentId: 'agent-2' })
+ const out = await rpc<{ tasks: WireTask[] }>(port, 'ListTasks', {})
+ return out.tasks
+ })
+ expect(tasks).toHaveLength(1)
+ expect(tasks[0]!.metadata?.agentId).toBe('agent-2')
+ })
+
+ it('keeps a follow-up on its task’s original skill, whatever the selector says', async () => {
+ const bin = fakeClaude('claude-followup.sh', [textLine('First.'), resultLine()])
+ const tasks = await withServer(bin, async (port) => {
+ const first = await runTurn(port, 'start here', { agentId: 'agent-3' })
+ const contextId = first[0]!.contextId!
+ // Same conversation, a different skill named. Moving a live context between skills mid-thread
+ // would split one chat across two agents in the session list.
+ await runTurn(port, 'and again', { contextId, agentId: 'scratch' })
+ const out = await rpc<{ tasks: WireTask[] }>(port, 'ListTasks', { contextId })
+ return out.tasks
+ })
+ expect(tasks).toHaveLength(2)
+ expect(tasks.map((t) => t.metadata?.agentId)).toEqual(['agent-3', 'agent-3'])
+ })
+
+ it('still answers a plain A2A client that names no skill at all', async () => {
+ // HP-107 is a MAY. The conformance runner sends no metadata, and a turn must not fail for it.
+ const bin = fakeClaude('claude-noselector.sh', [textLine('Fine.'), resultLine()])
+ const tasks = await withServer(bin, async (port) => {
+ await runTurn(port, 'no selector')
+ const out = await rpc<{ tasks: WireTask[] }>(port, 'ListTasks', {})
+ return out.tasks
+ })
+ expect(tasks[0]!.metadata?.agentId).toBe('scratch')
+ })
+})
+
describe('autonomous.GetContextHistory — a whole context, paged (HP-304)', () => {
const CONTEXT = 'ctx-history'
const TURNS = 6 // → 12 messages: user, assistant, user, assistant, …
diff --git a/provider/example-provider/src/server.ts b/provider/example-provider/src/server.ts
index 49f0d407c..1bd8b6c13 100644
--- a/provider/example-provider/src/server.ts
+++ b/provider/example-provider/src/server.ts
@@ -128,10 +128,10 @@ async function handle(req: IncomingMessage, res: ServerResponse, deps: Deps): Pr
/**
* Which configured agent a message targets.
*
- * NOTE — spec gap: A2A carries no "which skill" selector on a Message, and the profile never says how
- * a client picks one. This reads `message.metadata['autonomous.ai/agentId']` and otherwise falls
- * back to the first configured agent, which keeps plain A2A clients (including the conformance
- * runner) working. Worth a clause in the spec.
+ * HP-107 — A2A carries no "which skill" selector on a Message, so the profile puts one in
+ * `Message.metadata` as `autonomous.ai/agentId`. Falling back to the first configured agent keeps
+ * plain A2A clients (including the conformance runner) working — but it is only ever a fallback: a
+ * client that sends nothing gets every conversation filed under the same skill.
*/
function pickAgent(deps: Deps, message: Message | undefined): AgentEntry {
const requested = (message as { metadata?: Record<string, unknown> } | undefined)?.metadata?.['autonomous.ai/agentId']
@@ -191,7 +191,15 @@ async function sendStreamingMessage(res: ServerResponse, deps: Deps, params: Rec
}
const contextId = resuming?.contextId ?? (typeof incoming.contextId === 'string' && incoming.contextId ? incoming.contextId : `ctx-${Date.now()}`)
- const agent = resuming ? agentById(deps, resuming.agentId) ?? pickAgent(deps, incoming) : pickAgent(deps, incoming)
+ // Which skill runs this turn, most specific first. A conversation belongs to ONE skill for its
+ // whole life: the context was bound to one when it was created, and honouring a selector that
+ // disagrees would split a single chat across two agents in the client's session list — the client
+ // scopes that list to one agent, so half the thread would simply vanish from each.
+ const known = deps.store.context(contextId)
+ const agent =
+ (resuming ? agentById(deps, resuming.agentId) : undefined)
+ ?? (known ? agentById(deps, known.agentId) : undefined)
+ ?? pickAgent(deps, incoming)
const context = deps.store.ensureContext(contextId, agent.id)
const taskId = deps.store.nextTaskId()
diff --git a/provider/spec/README.md b/provider/spec/README.md
index 4747293fe..fdc41cd09 100644
--- a/provider/spec/README.md
+++ b/provider/spec/README.md
@@ -140,6 +140,19 @@ Schema for the extension entries: `schema/agent-card.ext.json`.
> involved. A provider that cannot accept images MUST fail the task with a clear message rather than
> silently discarding them; silent loss reads to the user as the agent ignoring what they sent.
+> **HP-107** A client MAY name the skill a turn belongs to in `Message.metadata` as
+> `autonomous.ai/agentId`, matching an `AgentCard.skills[].id`. A2A has no skill selector on a
+> Message, so without this a provider serving more than one skill can only guess — and a provider
+> that guesses "the first one" attributes every conversation to the same skill no matter which one
+> the user picked. A provider MAY ignore the field and choose its own skill; it MUST NOT fail a turn
+> because of it.
+>
+> The field selects a skill only when there is nothing more specific: a turn continuing an existing
+> `contextId`, or carrying a `taskId`, keeps the skill that conversation already belongs to, whatever
+> the field says. A conversation belongs to one skill for its whole life — the client's session list
+> is scoped to a single agent (HP-204), so a thread that changed skill mid-way would lose half its
+> turns from each agent's list.
+
---
## 6. History (HP-2xx)
@@ -162,6 +175,12 @@ than recommended: without them, a page refresh loses the conversation.
> then mark the response so the client can tell the user the view is partial. Silent truncation is a
> violation.
+> **HP-204** A task SHOULD carry `metadata.agentId` — the `AgentCard.skills[].id` whose skill ran it.
+> The client's model is machine → agent → session, so its session list is always scoped to ONE agent;
+> a task that does not say which skill it belongs to cannot be placed in that list, and selecting an
+> agent then shows either every conversation on the machine or none of them. A provider serving a
+> single skill MAY omit it: with one skill there is nothing to disambiguate.
+
---
## 7. Event vocabulary on `Part.metadata`
@@ -414,8 +433,8 @@ implemented 0.1.0, contact us — that is a case we did not think existed.
| HP-001 … HP-004 | Target revision and canonical base |
| HP-010 … HP-013 | Transport and authentication |
| HP-020 … HP-023 | Agent Card |
-| HP-100 … HP-106 | Messaging |
-| HP-200 … HP-203 | History |
+| HP-100 … HP-107 | Messaging |
+| HP-200 … HP-204 | History |
| HP-210 … HP-220 | Event vocabulary and projections |
| HP-300 … HP-311 | Extensions |
| HP-400 | Unknown frames |