Skip to content

Worked example

This page walks through a single, concrete flow: an AI coding agent, driven by the a2acli skill, discovers an agent, finds a skill on its card, and invokes it — all deterministically, with --output json. It adapts Scenario E (day-to-day CLI operation) from the repository’s Agent Skills Guide.

The three skills compose across the lifecycle; this example is the “production operation” stage on the right of the workflow:

The a2acli skills workflow: a2a-expose designs and implements an A2A exposure, a2a-conformance audits it against the spec, and a2acli operates the live agent — discovering capabilities, authenticating, and sending tasks.

“Discover the skills on http://localhost:9001 and run the summarize skill on this text.”

This matches the a2acli skill’s trigger keywords, so the agent activates it and follows its Critical Rules.

  1. The skill requires a2acli on PATH, so the agent checks it first:

    Terminal window
    a2acli version

    If this fails, the agent installs the binary or stops cleanly — it does not guess. See Installation.

  2. The agent fetches the AgentCard as machine-readable JSON — never the TUI:

    Terminal window
    a2acli discover --service-url http://localhost:9001 --output json

    It reads the skills array to confirm a summarize skill exists:

    {
    "name": "Example Agent",
    "skills": [
    { "id": "summarize", "name": "Summarize", "description": "Summarize text" }
    ]
    }

    See Discovery & Identity for the full card shape.

  3. send blocks by default and returns a single JSON document once the task reaches a terminal state — the agent adds no --wait and no --stream:

    Terminal window
    a2acli send "Summarize this text: ..." \
    --service-url http://localhost:9001 \
    --skill summarize \
    --output json
  4. The agent inspects status.state to branch on success or failure, then reads the produced artifacts:

    {
    "id": "task-abc123",
    "status": { "state": "TASK_STATE_COMPLETED" },
    "artifacts": [
    {
    "name": "summary",
    "parts": [{ "text": "A concise summary of the input text." }]
    }
    ]
    }
    • TASK_STATE_COMPLETED → read artifacts and return the result.
    • TASK_STATE_FAILED → surface the failure; the error envelope (on stdout) carries error.code, error.message, and error.hint.

    The process exit code confirms the outcome for scripting: 0 success, 2 usage error, 1 any other failure.

Against an OAuth 2.1-protected agent, the agent logs in once (a human completes the browser flow), after which every command reuses the stored token automatically:

Terminal window
# One-time interactive login
a2acli auth login --service-url https://agent.example.com
# Subsequent commands auto-authenticate — no --token needed
a2acli send "Summarize this text: ..." \
--service-url https://agent.example.com \
--skill summarize \
--output json

For a fully non-interactive runtime, the agent retrieves the stored token and passes it explicitly:

Terminal window
TOKEN=$(a2acli auth token --service-url https://agent.example.com)
a2acli send "Summarize this text: ..." \
--service-url https://agent.example.com \
--token "$TOKEN" \
--output json

See Configuration & Auth for the full auth workflow.