Skip to content
Closed
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
109 changes: 109 additions & 0 deletions .github/workflows/tck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: ACP TCK

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read

env:
TCK_COMMIT: 7c71c4d1af0994e73bdc100c9f7f6b98f2319cda # v0.5.0
TCK_SPEC_REVISION: 3ea94133bb4e7cfdb1105df75660ff83e66acf62
PYTHON_VERSION: "3.14.5"

jobs:
agent-stdio:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
# TCK v1.32.0 unstable vs SDK schema-v1.35.0.
- protocol: 1
name: agent-stdio (v1)
sdk-schema: schema
sdk-bindings: src/acp
tck-schema-blob: 4f18b3e7e90d8d65d413d27b750aa87b1fe9024c
tck-meta-blob: 2736f7fc75263e8fe18545de936b905da6e15436
# Diagnostic: TCK alpha.16 vs SDK alpha.7; keep the native failure visible.
- protocol: 2
name: agent-stdio (v2 diagnostic)
sdk-schema: schema/v2
sdk-bindings: src/acp/experimental/v2
tck-schema-blob: 819dc3d7bea6022f673b7d6a03c6fc2f831b25b8
tck-meta-blob: 8854425691cc15acdc82569facc1467494e2e7d6
steps:
- name: Check out SDK
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
with:
persist-credentials: false

- name: Install uv
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e
with:
version: "0.11.14"
enable-cache: true

- name: Install current SDK checkout
run: uv sync --locked --no-dev --python "$PYTHON_VERSION"

- name: Check out pinned ACP TCK
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
with:
repository: agentclientprotocol/acp-tck
ref: ${{ env.TCK_COMMIT }}
path: build/acp-tck
persist-credentials: false

- name: Run full ACP TCK suite
shell: bash
env:
PROTOCOL: ${{ matrix.protocol }}
SDK_SCHEMA: ${{ matrix.sdk-schema }}
SDK_BINDINGS: ${{ matrix.sdk-bindings }}
TCK_SCHEMA_BLOB: ${{ matrix.tck-schema-blob }}
TCK_META_BLOB: ${{ matrix.tck-meta-blob }}
run: |
mkdir -p build/tck
tck="$PWD/build/acp-tck"
vendored="$tck/src/tck/v$PROTOCOL/schema"
{
echo "SDK commit: $(git rev-parse HEAD)"
echo "SDK schema: $(cat "$SDK_SCHEMA/VERSION")"
git diff --exit-code HEAD -- "$SDK_SCHEMA" "$SDK_BINDINGS/schema.py" "$SDK_BINDINGS/meta.py"
git ls-files -s -- "$SDK_SCHEMA/schema.json" "$SDK_SCHEMA/meta.json" \
"$SDK_BINDINGS/schema.py" "$SDK_BINDINGS/meta.py"
sdk_import=$(.venv/bin/python -c 'import acp; print(acp.__file__)')
echo "SDK import: $sdk_import"
test "$sdk_import" = "$PWD/src/acp/__init__.py"
echo "TCK commit: $(git -C "$tck" rev-parse HEAD)"
echo "TCK spec revision: $TCK_SPEC_REVISION"
test "$(git -C "$tck" rev-parse HEAD)" = "$TCK_COMMIT"
grep -F "SCHEMA_REVISION = \"$TCK_SPEC_REVISION\"" "$vendored/../protocol.py"
test "$(git hash-object "$vendored/schema.unstable.json")" = "$TCK_SCHEMA_BLOB"
test "$(git hash-object "$vendored/meta.unstable.json")" = "$TCK_META_BLOB"
echo "TCK schema/meta blobs: $TCK_SCHEMA_BLOB $TCK_META_BLOB"
} 2>&1 | tee build/tck/tck.log

status=0
uv run --project "$tck" --locked --no-dev --python "$PYTHON_VERSION" acp-tck \
--protocol-version "$PROTOCOL" --timeout 5 --cancel-prompt wait_for_cancel \
--report-json "$PWD/build/tck/report.json" -- \
"$PWD/.venv/bin/python" "$PWD/tests/tck/agent_v$PROTOCOL.py" \
>>build/tck/tck.log 2>&1 || status=$?
printf '%s\n' "$status" >build/tck/exit-code.txt
tail -n 30 build/tck/tck.log
exit "$status"

- name: Upload TCK report, log and exit code
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: acp-tck-v${{ matrix.protocol }}
path: build/tck/
if-no-files-found: warn
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ See real adopters like kimi-cli in the [Use Cases list](https://agentclientproto
| Quickstart | <https://agentclientprotocol.github.io/python-sdk/quickstart/> |
| Use cases | <https://agentclientprotocol.github.io/python-sdk/use-cases/> |
| Contrib helpers | <https://agentclientprotocol.github.io/python-sdk/contrib/> |
| ACP TCK checks | <https://agentclientprotocol.github.io/python-sdk/tck/> |
| Releasing workflow | <https://agentclientprotocol.github.io/python-sdk/releasing/> |
| Examples | <https://github.com/agentclientprotocol/python-sdk/tree/main/examples> |
| Tests | <https://github.com/agentclientprotocol/python-sdk/tree/main/tests> |
Expand All @@ -63,6 +64,7 @@ See real adopters like kimi-cli in the [Use Cases list](https://agentclientproto
- `make install` provisions the `uv` virtualenv and installs pre-commit hooks.
- `make check` runs Ruff formatting/linting, type analysis, dependency hygiene, and lock verification.
- `make test` executes `pytest` (with doctests) inside the managed environment.
- See [ACP TCK checks](docs/tck.md) to run the pinned suites locally.
- `ACP_SCHEMA_VERSION=<ref> make gen-all` refreshes protocol artifacts when the schema advances.

Keep docs and examples current whenever you ship public API or transport changes, and prefer Conventional Commits (`feat:`, `fix:`, etc.) when submitting patches.
Expand Down
19 changes: 19 additions & 0 deletions docs/tck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Run the ACP TCK locally

From the SDK root, run the full suite for `version=1` or `version=2`:

```sh
uv sync --locked --no-dev --python 3.14.5
mkdir -p build/tck
git clone https://github.com/agentclientprotocol/acp-tck build/acp-tck
git -C build/acp-tck checkout --detach 7c71c4d1af0994e73bdc100c9f7f6b98f2319cda
version=1
uv run --project build/acp-tck --locked --no-dev --python 3.14.5 acp-tck \
--protocol-version "$version" --timeout 5 --cancel-prompt wait_for_cancel \
--report-json "$PWD/build/tck/v$version.json" -- \
"$PWD/.venv/bin/python" "$PWD/tests/tck/agent_v$version.py"
```

The CLI writes its native JSON report and returns its own exit code. CI uploads that report,
the log, and the exit code for each lane, including failures. Treat v2 as diagnostic: the
TCK's alpha.16 snapshot differs from the SDK's alpha.7 snapshot.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ nav:
- Use Cases: use-cases.md
- Web Transport (HTTP/WS): web-transport.md
- Experimental Protocol v2: experimental-v2.md
- ACP TCK: tck.md
- Experimental Contrib: contrib.md
- Releasing: releasing.md
- 0.11 Migration Guide: migration-guide-0.11.md
Expand Down
115 changes: 115 additions & 0 deletions tests/tck/agent_v1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""Deterministic ACP v1 agent for exercising the SDK with the external TCK.

This probe supplies only application state. The SDK owns stdio framing, routing,
model validation, serialization, and JSON-RPC errors.
"""

from __future__ import annotations

import asyncio
from typing import Any, cast
from uuid import uuid4

from acp import PROTOCOL_VERSION, Agent, Client, RequestError, run_agent
from acp.schema import (
AgentCapabilities,
AgentMessageChunk,
AudioContentBlock,
CloseSessionResponse,
EmbeddedResourceContentBlock,
ImageContentBlock,
Implementation,
InitializeResponse,
ListSessionsResponse,
NewSessionResponse,
PromptResponse,
ResourceContentBlock,
SessionCapabilities,
SessionCloseCapabilities,
SessionInfo,
SessionListCapabilities,
TextContentBlock,
)

CANCEL_PROMPT = "wait_for_cancel"
ContentBlock = (
TextContentBlock | ImageContentBlock | AudioContentBlock | ResourceContentBlock | EmbeddedResourceContentBlock
)


class ProbeAgent:
"""A plain class so unimplemented Protocol methods do not become handlers."""

def __init__(self) -> None:
self._client: Client | None = None
self._sessions: dict[str, SessionInfo] = {}
self._pending: dict[str, asyncio.Event] = {}

def on_connect(self, client: Client) -> None:
self._client = client

async def initialize(self, protocol_version: int, **kwargs: Any) -> InitializeResponse:
return InitializeResponse(
protocol_version=PROTOCOL_VERSION,
agent_capabilities=AgentCapabilities(
session_capabilities=SessionCapabilities(
list=SessionListCapabilities(), close=SessionCloseCapabilities()
),
),
agent_info=Implementation(name="python-sdk-tck-v1", version="1"),
)

async def new_session(self, cwd: str, **kwargs: Any) -> NewSessionResponse:
session_id = uuid4().hex
self._sessions[session_id] = SessionInfo(session_id=session_id, cwd=cwd)
return NewSessionResponse(session_id=session_id)

async def list_sessions(
self, cwd: str | None = None, cursor: str | None = None, **kwargs: Any
) -> ListSessionsResponse:
if cursor is not None:
# This in-memory list never issues a continuation cursor.
raise RequestError.invalid_params({"details": "unknown session list cursor"})
return ListSessionsResponse(sessions=[s for s in self._sessions.values() if cwd is None or s.cwd == cwd])

async def close_session(self, session_id: str, **kwargs: Any) -> CloseSessionResponse:
self._sessions.pop(session_id, None)
await self.cancel(session_id)
return CloseSessionResponse()

async def prompt(self, session_id: str, prompt: list[ContentBlock], **kwargs: Any) -> PromptResponse:
if session_id not in self._sessions:
error = RequestError.resource_not_found()
error.data = {"sessionId": session_id}
raise error
assert self._client is not None
wait_for_cancel = (
len(prompt) == 1 and isinstance(prompt[0], TextContentBlock) and prompt[0].text == CANCEL_PROMPT
)
event = asyncio.Event() if wait_for_cancel else None
if event is not None:
self._pending[session_id] = event
try:
await self._client.session_update(
session_id=session_id,
update=AgentMessageChunk(content=TextContentBlock(text="ready")),
)
if event is not None:
await event.wait()
return PromptResponse(stop_reason="cancelled" if event is not None else "end_turn")
finally:
if event is not None:
self._pending.pop(session_id, None)

async def cancel(self, session_id: str, **kwargs: Any) -> None:
if event := self._pending.get(session_id):
event.set()


async def main() -> None:
# The public Protocol lists optional handlers that this probe intentionally omits.
await run_agent(cast(Agent, ProbeAgent()))


if __name__ == "__main__":
asyncio.run(main())
Loading
Loading