Skip to content

ci(smoke-test): send integer ACP protocolVersion and poll for handshake - #1614

Merged
thepagent merged 3 commits into
mainfrom
fix/smoke-test-acp-handshake
Nov 22, 2026
Merged

thepagent merged 3 commits into
mainfrom
fix/smoke-test-acp-handshake

Conversation

@chaodu-agent

@chaodu-agent chaodu-agent commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

What problem does this solve?

smoke-test (Dockerfile.mimocode, ...) failed twice on #1613 even though that PR does not touch the mimocode image (run 44957594380, run 44936871726).

The root cause is in the smoke test itself. For every agent except codex, the initialize request sends "protocolVersion":"2025-03-26", which is an MCP-style string. ACP v1 requires an integer. In the last green run (44939206202), seven agents rejected the handshake with Invalid params ... expected number, received string: opencode, claude, gemini, kimi, cursor, mimocode, and pi. Each then fell back to <agent> --help. For mimocode, that fallback is intermittently non-zero, so the job flakes. For the other six, the ACP check silently degrades to a --help check.

Discord Discussion URL: N/A (maintainer-requested fix from the #1613 review thread)

Review Contract

Goal

Make the docker smoke test send a spec-valid ACP initialize request, so that agents that speak ACP pass the handshake instead of falling back to --help. This also removes the mimocode flake.

Non-goals

Removing the --help fallback for agents that never answer. Agents that return nothing within the timeout keep the existing fallback. A reply that rejects initialize is no longer hidden behind it.

Accepted Residual Risks

An agent that previously passed only through --help might now return a result without protocolVersion. It would still fall back to --help, which is the same as today. The polling loop can add up to 30 s per job when an agent never answers (today: a fixed 5 s).

Acceptance Criteria

  • Every smoke-test matrix leg passes on this PR.
  • The mimocode leg logs ACP handshake ok instead of falling back to CLI check.
  • No leg logs expected number, received string.

Follow-ups

Find out why kiro-cli does not answer initialize within 30 s, then consider making the no-response case fatal. Share the probe with docker-smoke-test-unified.yml, which still uses sleep 5 and grep -m1.

At a Glance

before: initialize(protocolVersion="2025-03-26") -> Invalid params -> --help fallback (flaky for mimo)
after:  initialize(protocolVersion=1)            -> result         -> handshake ok

Prior Art & Industry Research

Not applicable. This is a CI test fix. The ACP schema defines protocolVersion as an integer (ProtocolVersion, currently 1): https://agentclientprotocol.com/protocol/initialization

Proposed Solution

In .github/workflows/docker-smoke-test.yml:

  • Send protocolVersion: 1 to every agent; drop the codex-only branch.
  • Poll docker logs once per second for up to 30 s instead of a fixed sleep 5. Kiro returned no response within 5 s in the last green run.
  • Match the reply line by line (jq -R 'fromjson? | select(...)'): only a JSON-RPC 2.0 response with result or error and id: 1 counts (or an error with id: null), so notifications, agent requests, logs, and malformed lines are skipped.
  • Treat the reply as success only when jsonrpc == "2.0" and result.protocolVersion == 1. agentInfo is optional in ACP (cursor and grok omit it); the agent name is printed when present.
  • Fail the leg when the matched reply is a JSON-RPC error or a different version. The --help fallback applies only when no reply arrives within 30 s.
  • Track the background docker attach PID and remove the container and attach client in an EXIT trap.
  • Add the workflow file to its own paths filter, so changes to the smoke test run the smoke test.

Why this approach?

It fixes the request instead of retrying a flaky fallback, and it strengthens the check for seven agents that are silently skipping ACP today.

Alternatives Considered

  • Retry mimo --help or bump the mimocode pin: this hides the symptom and leaves the other six agents on the weaker check.
  • Make the handshake fatal for all agents now: stricter, but agents needing auth may not answer initialize offline. This is left as a follow-up once results are visible.

Validation

  • bash -n on the extracted step script with matrix placeholders substituted.
  • jq matching and assertion checked against sample output: notifications, malformed lines, and id: 2 are skipped; protocolVersion 2, "1", and a JSON-RPC error are rejected.
  • Step script run against a stub docker: an error reply exits 1, a valid reply passes, and no attach process is left running.
  • Full matrix result on this PR's CI run.

The non-codex smoke-test handshake sent protocolVersion "2025-03-26"
(an MCP-style string). ACP v1 requires an integer, so opencode, claude,
gemini, kimi, cursor, mimocode and pi all rejected initialize with
Invalid params and fell back to a bare --help check. For mimocode that
fallback is intermittently non-zero, which failed PR #1613 twice.

- send protocolVersion 1 to every agent
- poll docker logs for up to 30s instead of a fixed 5s sleep
- accept any initialize result with protocolVersion (agentInfo is
  optional in ACP), still printing the agent name when present
- run the workflow when the workflow file itself changes
@chaodu-agent

This comment has been minimized.

… error, clean up attach

- Select the initialize reply with id 1 per line (fromjson?), skipping
  notifications, logs, and malformed lines.
- Require jsonrpc 2.0 and result.protocolVersion == 1; agentInfo stays optional.
- A matched reply that is a JSON-RPC error or a different version now fails
  the leg instead of falling back to --help. The --help fallback applies only
  when no reply arrives within 30 s.
- Track the background docker attach PID and clean up the container and
  attach client in an EXIT trap.
…stale comment

- The selector now requires jsonrpc 2.0 and a result or error member, so an
  agent request or a JSON log line carrying id 1 no longer ends polling.
- A JSON-RPC error with id null (parse error) is also treated as a reply and
  fails the leg.
- Update the step comment: a rejected string version now fails the leg
  instead of falling through to --help.
@chaodu-agent

Copy link
Copy Markdown
Collaborator Author

Note

LGTM ✅ - All four round 1 findings and both round 2 findings are fixed. CI on b827ab6 passes all 15 smoke-test legs, with 13 legs completing a real ACP handshake and no agent returning an initialize error.

What This PR Does

The docker smoke test sent "protocolVersion":"2025-03-26" (a string) to every agent except codex. ACP v1 requires an integer, so strict agents rejected the handshake and the test silently fell back to <agent> --help, which flaked for mimocode. This PR sends protocolVersion: 1 to every agent, polls for the reply, checks it strictly, and fails the leg when an agent answers with an error.

How It Works

  • One INIT payload with protocolVersion: 1 for every matrix leg; the codex-only branch is removed.
  • A loop polls docker logs once per second for up to 30 s. Each line goes through jq -R 'fromjson? | select(...)', which keeps only a JSON-RPC 2.0 response (result or error) with id: 1, or an error with id: null. Notifications, agent requests, log lines, and malformed lines are skipped.
  • Success requires jsonrpc == "2.0" and result.protocolVersion == 1. agentInfo stays optional, as ACP specifies.
  • A matched reply that is an error or carries another version fails the leg. The --help fallback runs only when no reply arrives within 30 s.
  • A cleanup function in an EXIT trap removes the container and kills and reaps the background docker attach client.
  • The workflow file is added to its own paths filter.

CI Evidence (Docker Smoke Test run 44968670715, head b827ab6)

All 15 smoke-test legs pass. No leg logs expected number, received string, and no leg hits the new initialize was rejected branch.

Result Legs
ACP handshake ok antigravity, claude, codex, copilot, cursor, devin, gemini, grok, kimi, mimocode, native-sandbox, opencode, pi
No reply within 30 s, --help fallback kiro-cli, kiro-cli unified

The agents that need auth (for example gemini and pi, which advertise authMethods) return a valid initialize result rather than an error. Making error fatal therefore does not turn any current leg red.

Findings

# Severity Finding Location
1 🟢 JSON-RPC error and wrong-version replies now fail the leg; --help is reserved for no reply (round 1 F1, fixed) .github/workflows/docker-smoke-test.yml:174-190
2 🟢 The reply is matched by id and JSON-RPC response shape, not by the first { line (round 1 F2 and round 2 selector finding, fixed) .github/workflows/docker-smoke-test.yml:162-164
3 🟢 The success check asserts protocolVersion == 1 with agentInfo optional (round 1 F3, fixed) .github/workflows/docker-smoke-test.yml:174
4 🟢 The attach client and container are cleaned up in an EXIT trap (round 1 F4, fixed) .github/workflows/docker-smoke-test.yml:140-169
5 🟢 The step comment now describes the new failure behavior (round 2 stale-comment finding, fixed) .github/workflows/docker-smoke-test.yml:136-137
6 🟢 CI shows the fix works: 13 of 15 legs moved from the --help fallback to a real handshake -
Finding Details

🟢 F1: Errors no longer hide behind --help

Round 1 found that a JSON-RPC error reply was treated like no reply, so non-codex legs passed on --help. The new elif [ -n "$RESPONSE" ] branch prints the reply and exits 1. The --help fallback now prints no response within 30 s, which matches when it runs.

🟢 F2: Reply matching

Round 1 found that grep -m1 '^{' could stop on a notification or another id. Round 2 found that matching on id == 1 alone could still stop on an agent request or a JSON log line carrying id: 1. The selector now also requires jsonrpc == "2.0" and a result or error member. Fixture checks against a notification, a log object with id: 1, an agent request with id: 1, a malformed line, an id: 2 result, an id: null error, and a valid result selected only the last two. fromjson? is available in jq 1.7 on the Ubuntu 24.04 runners.

🟢 F3: Version assertion

jq == is type-strict, so protocolVersion values 2 and "1" are rejected. cursor and grok return valid results without agentInfo and still pass.

🟢 F4: Cleanup

ATTACH_PID=$! holds the docker attach PID (the last command in the background pipeline). cleanup removes the container, kills and waits for the attach client, and clears both variables, so the EXIT trap that runs again later does nothing. A stub-docker run of the step confirmed that an error reply exits 1, a valid reply passes, and no attach process is left running.

🟢 F5: Comment accuracy

The comment above INIT said a rejected string version falls through to --help. It now says that case fails the leg.

🟢 F6: Verified by CI

See CI Evidence above. The seven agents that rejected the string version before this PR (opencode, claude, gemini, kimi, cursor, mimocode, pi) all complete the handshake.

Addressing Reviewer Feedback

Round 1 findings

F1: a JSON-RPC error response falls back to --help and passes.

✅ Addressed in c990f26: matched errors and wrong versions exit 1.

F2: polling stops at the first line starting with { without checking id: 1.

✅ Addressed in c990f26 and b827ab6: per-line id and response-shape matching.

F3: any truthy protocolVersion passes.

✅ Addressed in c990f26: asserts jsonrpc == "2.0" and protocolVersion == 1.

F4: the background docker attach PID is never waited on or killed.

✅ Addressed in c990f26: EXIT trap with explicit cleanup.

Round 2 review

The step comment still describes falling through to --help.

✅ Addressed in b827ab6.

The selector matches any object with id: 1, not only a JSON-RPC response.

✅ Addressed in b827ab6: requires jsonrpc == "2.0" and result or error.

A JSON-RPC parse error with id: null would slide into the --help path.

✅ Addressed in b827ab6: an error with id: null is selected and fails the leg.

Thirty seconds of silence does not prove the agent needs auth; a crash or hang can also be silent and then pass on --help.

ℹ️ Accepted as a follow-up: the PR's Review Contract lists the no-response fallback as a non-goal. Only the two kiro-cli legs are silent today, so this is tracked together with the kiro-cli investigation below.

If docker run -d fails, the loop polls an empty container id for 30 s.

ℹ️ Accepted: GitHub Actions runs this step with bash -e, and a failing CID=$(docker run ...) assignment exits the step immediately, so the loop does not run.

jq | head -n1 relies on || true without pipefail.

ℹ️ Accepted: correct today; anyone adding set -o pipefail to this step must keep the SIGPIPE case masked.

Security: no new injection, secret, container, or dependency surface; the matrix values are repo-controlled constants.

ℹ️ Noted: no action needed.

Follow-ups (non-blocking)
  • kiro-cli does not answer initialize within 30 s. Both kiro-cli legs, including the default image, still use the --help fallback and pay the full 30 s. Find out why (auth gate, output buffering, or startup arguments), then consider making no-reply fatal or checking that the container is still running before falling back.
  • docker-smoke-test-unified.yml keeps the old probe. It already sends protocolVersion: 1 and checks exact agent names, but still uses sleep 5 and grep -m1 '^{'. A shared probe script under .github/scripts/ with fixture tests would stop the two workflows from drifting.
  • Probe harness. A small stdio JSON-RPC client with real timeouts and distinct exit codes for ok, error, and no reply would replace the shell polling.
Baseline Check
  • PR opened: 2026-11-21
  • Head: b827ab6fdcfdb536d0ebb8f3a5ea1eb1c5bd89b3
  • Base: main, merge-base b5f0ea8349dc28a5fbcd09cb9f07269300945c94
  • Diff: 1 file, +41/-12, .github/workflows/docker-smoke-test.yml
  • Main already has: an integer protocolVersion and a strict failure for codex only
  • Net-new value: an integer version for the other 14 legs, strict reply matching and version checks, fatal error replies, polling instead of a fixed sleep, and cleanup of the attach client
What's Good (🟢)
  • Fixes the cause (the request payload) instead of retrying the flaky fallback.
  • Makes the check stricter for 13 agents while keeping a fallback only for silent agents.
  • The Review Contract and Follow-ups are kept in sync with the code.

5. Three Reasons We Might Not Need This PR

  1. Silent agents still pass on --help. For kiro-cli, the most-used image, the ACP check still gates nothing until the no-reply case is understood.
  2. The version change alone fixes the flake. The stricter matching and cleanup protect against regressions no agent shows today.
  3. The unified workflow is not covered. Until the probe is shared, the two workflows check ACP differently.

@thepagent
thepagent merged commit 53e0c68 into main Nov 22, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants