Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,9 @@ jobs:
cache-suffix: agent-py${{ matrix.python-version }}
- name: Install the shim against the in-tree core
# Agent's lock for its own tools, then Flow's for the core it tests.
# The a2a extra lets the A2A server and signed-card tests run.
run: >-
python ../../scripts/ci/locked_install.py --lock 'packages/agent[dev]' --lock 'packages/flow[agent]'
python ../../scripts/ci/locked_install.py --lock 'packages/agent[dev]' --lock 'packages/flow[agent,a2a]'
--editable packages/types --editable packages/flow --editable packages/agent
- name: Confirm the in-tree Flow is the one installed
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
| A2A (Agent2Agent) protocol adapter: `openadapt agent serve --a2a` serves compiled workflows as A2A 1.0 skills with the official `a2a-sdk` (`openadapt[a2a]`): Agent Card at `/.well-known/agent-card.json`, JSON-RPC and HTTP+JSON, runs as tasks with status updates, the run's receipt as a handoff artifact when Flow wrote one (sandbox and strict at-rest runs have none), a `verify_handoff` skill, and the draft extension `https://openadapt.ai/extensions/handoff-receipt/v1`. Every call passes the MCP server's gate; person confirmations are not served; only `done` is completed. Loopback by default, a bearer token anywhere else, browser `Origin` and unknown `Host` refused | On main ([#2414](https://github.com/OpenAdaptAI/OpenAdapt/pull/2414)) | Synthetic: the official `a2a-sdk` 1.3.1 client against the server over HTTP on 127.0.0.1, with a governed run whose Flow process is stubbed and whose receipt Flow's writer signs; the official A2A TCK (a2aproject/a2a-tck at 5e6f37c): 110 automated checks passed and 11 failed, MUST 76.0%. The failures are 10 SDK-scenario tests that expect the TCK's own scripted agent, and the SDK's error Content-Type ([benchmark/a2a_tck](packages/flow/benchmark/a2a_tck/README.md)) | `openadapt_flow/agent/a2a_server.py`, [A2A.md](packages/flow/docs/A2A.md) |
| A2A (Agent2Agent) protocol adapter: `openadapt agent serve --a2a` serves compiled workflows as A2A 1.0 skills with the official `a2a-sdk` (`openadapt[a2a]`): Agent Card at `/.well-known/agent-card.json`, signed (A2A 1.0 section 8.4, EdDSA JWS by the Seal key that signs receipts; no server if the key can't be opened), JSON-RPC and HTTP+JSON, runs as tasks with status updates, the run's receipt as a handoff artifact when Flow wrote one (sandbox and strict at-rest runs have none), a `verify_handoff` skill, and the draft extension `https://openadapt.ai/extensions/handoff-receipt/v1`. Every call passes the MCP server's gate; person confirmations are not served; only `done` is completed. Loopback by default, a bearer token anywhere else, browser `Origin` and unknown `Host` refused | On main ([#2414](https://github.com/OpenAdaptAI/OpenAdapt/pull/2414)) | Synthetic: the official `a2a-sdk` 1.3.1 client against the server over HTTP on 127.0.0.1, with a governed run whose Flow process is stubbed and whose receipt Flow's writer signs; the official A2A TCK (a2aproject/a2a-tck at 5e6f37c, 2026-11-30, sandbox server with `--a2a-tck-scenarios`): 121 automated checks passed, 0 failed, 142 skipped (gRPC, push, cancel, auth scenarios), MUST 78.7% because the TCK counts skipped and manual checks as not passed ([benchmark/a2a_tck](packages/flow/benchmark/a2a_tck/README.md)); a second implementation, the A2A JavaScript SDK 1.3.0, ran a workflow and verified a second key's handoff over JSON-RPC and HTTP+JSON and checked the card signature with independent JWS and RFC 8785 libraries, all on one computer ([benchmark/a2a_interop](packages/flow/benchmark/a2a_interop/README.md)); the card signature verified by the `a2a-sdk` verifier and refused when changed, unpinned or relabelled (the TCK leaves signing to manual checks) | `openadapt_flow/agent/a2a_server.py`, [A2A.md](packages/flow/docs/A2A.md) |
317 changes: 304 additions & 13 deletions packages/agent/tests/test_handoff_e2e.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/flow/benchmark/a2a_interop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
55 changes: 55 additions & 0 deletions packages/flow/benchmark/a2a_interop/2026-11-30/evidence.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"date": "2026-11-30",
"server": {
"command": "openadapt-agent serve --a2a --sandbox-engine simulated --handoff-keys REGISTRY",
"openadapt_flow": "4.0.1"
},
"client": {
"node": "v22.22.0",
"packages": {
"@a2a-js/sdk": "1.3.0",
"canonicalize": "2.1.0",
"jose": "6.2.19"
}
},
"results": {
"card": {
"signed_by_pinned_key": true,
"tampered_refused": true,
"other_key_refused": true,
"spec_example_canonical": true
},
"JSONRPC": {
"run_completed": true,
"run_state": 3,
"run_artifacts": [
"run_result"
],
"run_status_text": "Simulated sandbox result (no app was opened): Saved the change and read the record back to confirm it.",
"run_outcome": "done",
"handoff_integrity": "intact",
"handoff_signer_roles": [
"customer_key"
],
"handoff_outcome": "UNKNOWN",
"tampered_integrity": "refused",
"tampered_reason": "bad_signature"
},
"HTTP+JSON": {
"run_completed": true,
"run_state": 3,
"run_artifacts": [
"run_result"
],
"run_status_text": "Simulated sandbox result (no app was opened): Saved the change and read the record back to confirm it.",
"run_outcome": "done",
"handoff_integrity": "intact",
"handoff_signer_roles": [
"customer_key"
],
"handoff_outcome": "UNKNOWN",
"tampered_integrity": "refused",
"tampered_reason": "bad_signature"
}
}
}
56 changes: 56 additions & 0 deletions packages/flow/benchmark/a2a_interop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# A second A2A implementation against `openadapt-agent serve --a2a`

The other tests of the A2A adapter use the Python `a2a-sdk`, which the server
is also built on. This check uses an implementation that shares no code with
OpenAdapt or the Python SDK:

- **Client.** The official A2A JavaScript SDK, `@a2a-js/sdk` (Apache-2.0).
- **Card signature.** Checked with `jose` (MIT) for the JWS and `canonicalize`
(Apache-2.0) for RFC 8785. Neither the server nor the Python SDK uses them.

The exact versions are pinned in `package-lock.json`. Nothing is copied into
this repository; `npm ci` installs them.

## What it does

`run_interop.py` does the setup and starts the server, and then `interop.mjs`
runs the checks:

1. Party A, a second key, signs a run receipt and a handoff document.
2. The sandbox server starts with `--handoff-keys` pinning Party A's key as
`customer_key`. The client pins the server's card key, which is the Seal
key that signs this computer's receipts.
3. The client checks the card signature. It also checks that a card with a
changed interface URL is refused, and so is a key it didn't pin.
4. Over JSON-RPC and again over HTTP+JSON, the client:
- runs `add_triage_note` (sandbox, simulated engine);
- sends Party A's handoff to `verify_handoff`;
- sends the same handoff with one signature byte changed.

```bash
npm ci
python run_interop.py --out 2026-11-30
```

## Result (2026-11-30, `2026-11-30/evidence.json`)

| Check | JSON-RPC | HTTP+JSON |
|---|---|---|
| Card signed by the pinned key | yes | (same card) |
| Changed card refused, unpinned key refused | yes | (same card) |
| Section 8.4.1 worked example canonicalized as the spec gives it | yes | (no server) |
| Run completed with outcome `done` | yes | yes |
| Party A's handoff: integrity | `intact`, signer role `customer_key` | `intact`, signer role `customer_key` |
| Handoff with a changed signature | refused, `bad_signature` | refused, `bad_signature` |

The handoff's outcome is `UNKNOWN` because Party A's receipt comes from a
report with no read-back. The verdict copies the receipt's outcome and never
upgrades it.

## What it doesn't show

- **The run carries no receipt.** The sandbox run is simulated and goes
through no Flow CLI process.
- **Both parties are on one computer.** Party A is a second key there, not
another organisation's system. No handoff has yet gone to a real outside
party.
206 changes: 206 additions & 0 deletions packages/flow/benchmark/a2a_interop/interop.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
// A second A2A implementation talks to `openadapt-agent serve --a2a`.
//
// The client is the official A2A JavaScript SDK (@a2a-js/sdk). The card
// signature is checked with jose (JWS) and canonicalize (RFC 8785), neither of
// which OpenAdapt or the Python a2a-sdk uses. Usage:
//
// node interop.mjs URL PINNED_CARD_KEY.json HANDOFF.json
//
// PINNED_CARD_KEY.json is {"kid": ..., "jwk": {...}}: the key the client chose
// to trust for this server's card. HANDOFF.json is a handoff document signed by
// another party whose key the server trusts. Prints one JSON result object.

import { readFileSync } from "node:fs";
import { randomUUID } from "node:crypto";
import canonicalize from "canonicalize";
import { base64url, flattenedVerify, importJWK } from "jose";
import { Role, TaskState } from "@a2a-js/sdk";
import { ClientFactory, ClientFactoryOptions } from "@a2a-js/sdk/client";

const [url, pinnedPath, handoffPath] = process.argv.slice(2);
const pinned = JSON.parse(readFileSync(pinnedPath, "utf8"));
const handoff = JSON.parse(readFileSync(handoffPath, "utf8"));
const results = {};

// -- the card signature (A2A 1.0 section 8.4) ---------------------------------------

// Field presence for canonicalization (section 8.4.1, rule 1), written from the
// spec and the lf.a2a.v1 proto, not from OpenAdapt's code. For each message type:
// `req` lists REQUIRED fields and the default each takes when absent (kept even
// when empty), `msg` names the type of each message-valued field (`[T]` for a
// repeated field, `{T}` for a map), `rep` lists repeated scalar fields, and
// `implicit` lists scalar fields without explicit presence (dropped at their
// default). Everything else present in the served JSON was set, so it stays.
const SCHEMA = {
AgentCard: {
req: { name: "", description: "", supportedInterfaces: [], version: "", capabilities: {},
defaultInputModes: [], defaultOutputModes: [], skills: [] },
msg: { supportedInterfaces: "[AgentInterface]", provider: "AgentProvider",
capabilities: "AgentCapabilities", securitySchemes: "{SecurityScheme}",
securityRequirements: "[SecurityRequirement]", skills: "[AgentSkill]" },
rep: [],
},
AgentInterface: { req: { url: "", protocolBinding: "", protocolVersion: "" }, implicit: ["tenant"] },
AgentProvider: { req: { url: "", organization: "" } },
AgentCapabilities: { msg: { extensions: "[AgentExtension]" } },
AgentExtension: { implicit: ["uri", "description", "required"] },
AgentSkill: {
req: { id: "", name: "", description: "", tags: [] },
rep: ["examples", "inputModes", "outputModes"],
msg: { securityRequirements: "[SecurityRequirement]" },
},
SecurityRequirement: { msg: { schemes: "{StringList}" } },
StringList: { rep: ["list"] },
SecurityScheme: {
msg: { apiKeySecurityScheme: "APIKeySecurityScheme", httpAuthSecurityScheme: "HTTPAuthSecurityScheme",
oauth2SecurityScheme: "OAuth2SecurityScheme",
openIdConnectSecurityScheme: "OpenIdConnectSecurityScheme", mtlsSecurityScheme: "MutualTls" },
},
APIKeySecurityScheme: { req: { location: "", name: "" }, implicit: ["description"] },
HTTPAuthSecurityScheme: { req: { scheme: "" }, implicit: ["description", "bearerFormat"] },
OAuth2SecurityScheme: { req: { flows: {} }, implicit: ["description", "oauth2MetadataUrl"] },
OpenIdConnectSecurityScheme: { req: { openIdConnectUrl: "" }, implicit: ["description"] },
MutualTls: { implicit: ["description"] },
};

const isDefault = (v) => v === "" || v === false || v === 0 || v === null;

function present(value, type) {
const spec = SCHEMA[type];
if (!spec) return value; // a type with no rules here (e.g. OAuthFlows) is kept as served
const out = {};
for (const [k, v] of Object.entries(value ?? {})) {
const kind = spec.msg?.[k];
if (kind?.startsWith("[")) {
const items = v.map((item) => present(item, kind.slice(1, -1)));
if (items.length || k in (spec.req ?? {})) out[k] = items;
} else if (kind?.startsWith("{")) {
const entries = Object.entries(v).map(([mk, mv]) => [mk, present(mv, kind.slice(1, -1))]);
if (entries.length || k in (spec.req ?? {})) out[k] = Object.fromEntries(entries);
} else if (kind) {
out[k] = present(v, kind);
} else if (spec.rep?.includes(k)) {
if (v.length || k in (spec.req ?? {})) out[k] = v;
} else if (spec.implicit?.includes(k)) {
if (!isDefault(v)) out[k] = v;
} else {
out[k] = v;
}
}
for (const [k, d] of Object.entries(spec.req ?? {})) {
if (!(k in out)) out[k] = typeof d === "object" && !Array.isArray(d) && spec.msg?.[k] ? present({}, spec.msg[k]) : d;
}
return out;
}

// The only JOSE header parameters accepted (RFC 7515 section 5.2): no crit,
// no jku, and no name in both the protected and unprotected headers.
function headerOk(header, unprotected) {
const prot = Object.keys(header);
const unprot = Object.keys(unprotected ?? {});
return prot.every((k) => ["alg", "kid", "typ"].includes(k))
&& unprot.every((k) => k === "jwk")
&& !unprot.some((k) => prot.includes(k))
&& (header.typ === undefined || header.typ === "JOSE");
}

async function verifyCard(card, key) {
const { signatures, ...rest } = card;
const payload = base64url.encode(canonicalize(present(rest, "AgentCard")));
for (const s of signatures ?? []) {
const header = JSON.parse(new TextDecoder().decode(base64url.decode(s.protected)));
if (!headerOk(header, s.header) || header.alg !== "EdDSA" || header.kid !== pinned.kid) continue;
try {
await flattenedVerify({ protected: s.protected, payload, signature: s.signature }, key, {
algorithms: ["EdDSA"],
});
return header.kid;
} catch {
// try the next signature
}
}
return null;
}

const card = await (await fetch(`${url}/.well-known/agent-card.json`)).json();
const key = await importJWK(pinned.jwk, "EdDSA");
const tampered = structuredClone(card);
tampered.supportedInterfaces[0].url = "http://evil.example/a2a/jsonrpc";
const other = await importJWK(
{ kty: "OKP", crv: "Ed25519", x: base64url.encode(new Uint8Array(32).fill(7)) },
"EdDSA",
);
results.card = {
signed_by_pinned_key: (await verifyCard(card, key)) === pinned.kid,
tampered_refused: (await verifyCard(tampered, key)) === null,
other_key_refused: (await verifyCard(card, other)) === null,
// The spec's worked example (section 8.4.1), plus the REQUIRED fields it leaves out.
spec_example_canonical:
canonicalize(present({ name: "Example Agent", description: "",
capabilities: { streaming: false, pushNotifications: false, extensions: [] }, skills: [] }, "AgentCard"))
=== '{"capabilities":{"pushNotifications":false,"streaming":false},"defaultInputModes":[],'
+ '"defaultOutputModes":[],"description":"","name":"Example Agent","skills":[],'
+ '"supportedInterfaces":[],"version":""}',
};


// -- runs and handoffs over both bindings -------------------------------------------

function message(data) {
return {
messageId: randomUUID(),
contextId: "",
taskId: "",
role: Role.ROLE_USER,
parts: [{ content: { $case: "data", value: data }, metadata: undefined, filename: "", mediaType: "application/json" }],
metadata: undefined,
extensions: [],
referenceTaskIds: [],
};
}

function artifactData(task, name) {
const artifact = (task.artifacts ?? []).find((a) => a.name === name);
const part = artifact?.parts.find((p) => p.content?.$case === "data");
return part?.content.value;
}

function tamper(doc) {
const copy = structuredClone(doc);
const sig = copy.receipt.signatures[0].sig;
copy.receipt.signatures[0].sig = (sig[0] === "A" ? "B" : "A") + sig.slice(1);
return copy;
}

for (const transport of ["JSONRPC", "HTTP+JSON"]) {
const factory = new ClientFactory(
ClientFactoryOptions.createFrom(ClientFactoryOptions.default, { preferredTransports: [transport] }),
);
const client = await factory.createFromUrl(url);
const send = (data) => client.sendMessage({ tenant: "", message: message(data), configuration: undefined, metadata: undefined });

const run = await send({
skill: "add_triage_note",
inputs: { note: "Made-up triage note for an interop test.", sandbox_case: "normal" },
request_id: `interop-${transport.replace(/[^A-Za-z0-9]/g, "")}-${randomUUID()}`,
});
const runResult = artifactData(run, "run_result");
const good = await send({ skill: "verify_handoff", handoff });
const bad = await send({ skill: "verify_handoff", handoff: tamper(handoff) });
const goodVerdict = artifactData(good, "verdict");
const badVerdict = artifactData(bad, "verdict");
results[transport] = {
run_completed: run.status?.state === TaskState.TASK_STATE_COMPLETED,
run_state: run.status?.state ?? null,
run_artifacts: (run.artifacts ?? []).map((a) => a.name),
run_status_text: run.status?.message?.parts?.map((p) => p.content?.value).join(" ") ?? null,
run_outcome: runResult?.outcome ?? null,
handoff_integrity: goodVerdict?.integrity ?? null,
handoff_signer_roles: goodVerdict?.signer_roles ?? null,
handoff_outcome: goodVerdict?.outcome ?? null,
tampered_integrity: badVerdict?.integrity ?? null,
tampered_reason: badVerdict?.reason ?? null,
};
}

console.log(JSON.stringify(results, null, 2));
Loading
Loading