From 8dd23797c94272974d211f96967230a9f08a01ff Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Sat, 21 Nov 2026 23:26:51 +0000 Subject: [PATCH 1/3] ci(smoke-test): send integer ACP protocolVersion and poll for handshake 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 --- .github/workflows/docker-smoke-test.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-smoke-test.yml b/.github/workflows/docker-smoke-test.yml index 8bce2aa2c..7f9b5ed5a 100644 --- a/.github/workflows/docker-smoke-test.yml +++ b/.github/workflows/docker-smoke-test.yml @@ -13,6 +13,7 @@ on: - 'Cargo.*' - '.github/scripts/node_base_arg.sh' - '.github/scripts/test_node_base_arg.sh' + - '.github/workflows/docker-smoke-test.yml' concurrency: group: smoke-test-${{ github.event.pull_request.number }} @@ -132,23 +133,27 @@ jobs: - name: Verify agent responds run: | - if [ "${{ matrix.variant.suffix }}" = "-codex" ]; then - INIT='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{},"clientInfo":{"name":"ci-test","version":"0.0.1"}}}' - else - INIT='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","clientCapabilities":{},"clientInfo":{"name":"ci-test","version":"0.0.1"}}}' - fi + # ACP v1 requires an integer protocolVersion. A string value is + # rejected with "Invalid params" by strict agents, which then fall + # through to the weaker --help check below. + INIT='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{},"clientInfo":{"name":"ci-test","version":"0.0.1"}}}' - # Start agent in background, send init, capture output with timeout + # Start agent in background, send init, and poll for the first + # JSON-RPC line instead of a fixed sleep: cold starts vary. CID=$(docker run -d -i --entrypoint sh openab-test${{ matrix.variant.suffix }} -c 'exec ${{ matrix.variant.agent }} ${{ matrix.variant.agent_args }} 2>/dev/null') echo "$INIT" | docker attach --no-stdin=false "$CID" & - sleep 5 - RESPONSE=$(docker logs "$CID" 2>/dev/null | grep -m1 '^{' || true) + RESPONSE="" + for _ in $(seq 1 30); do + RESPONSE=$(docker logs "$CID" 2>/dev/null | grep -m1 '^{' || true) + [ -n "$RESPONSE" ] && break + sleep 1 + done docker rm -f "$CID" >/dev/null 2>&1 echo "Response: $RESPONSE" - if [ -n "$RESPONSE" ] && echo "$RESPONSE" | jq -e '.result.agentInfo.name' > /dev/null 2>&1; then - AGENT_NAME=$(echo "$RESPONSE" | jq -r '.result.agentInfo.name') + if [ -n "$RESPONSE" ] && echo "$RESPONSE" | jq -e '.result.protocolVersion' > /dev/null 2>&1; then + AGENT_NAME=$(echo "$RESPONSE" | jq -r '.result.agentInfo.name // "unknown"') echo "✅ ACP handshake ok — agent=$AGENT_NAME" elif [ "${{ matrix.variant.suffix }}" = "-codex" ]; then echo "❌ Codex ACP handshake failed" From c990f267b3824ce9a277290fb2d4cc2a07357c6e Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 00:47:18 +0000 Subject: [PATCH 2/3] fix(review): match ACP reply by id, assert protocolVersion 1, fail on 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. --- .github/workflows/docker-smoke-test.yml | 35 ++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-smoke-test.yml b/.github/workflows/docker-smoke-test.yml index 7f9b5ed5a..5ab893e4a 100644 --- a/.github/workflows/docker-smoke-test.yml +++ b/.github/workflows/docker-smoke-test.yml @@ -138,28 +138,51 @@ jobs: # through to the weaker --help check below. INIT='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{},"clientInfo":{"name":"ci-test","version":"0.0.1"}}}' - # Start agent in background, send init, and poll for the first - # JSON-RPC line instead of a fixed sleep: cold starts vary. + CID="" + ATTACH_PID="" + cleanup() { + if [ -n "$CID" ]; then docker rm -f "$CID" >/dev/null 2>&1 || true; fi + if [ -n "$ATTACH_PID" ]; then + kill "$ATTACH_PID" 2>/dev/null || true + wait "$ATTACH_PID" 2>/dev/null || true + fi + CID="" + ATTACH_PID="" + } + trap cleanup EXIT + + # Start agent in background, send init, and poll for the reply to + # request id 1 instead of a fixed sleep: cold starts vary. Other + # JSON lines (notifications, logs, malformed output) are skipped. CID=$(docker run -d -i --entrypoint sh openab-test${{ matrix.variant.suffix }} -c 'exec ${{ matrix.variant.agent }} ${{ matrix.variant.agent_args }} 2>/dev/null') echo "$INIT" | docker attach --no-stdin=false "$CID" & + ATTACH_PID=$! RESPONSE="" for _ in $(seq 1 30); do - RESPONSE=$(docker logs "$CID" 2>/dev/null | grep -m1 '^{' || true) + RESPONSE=$(docker logs "$CID" 2>/dev/null \ + | jq -R -c 'fromjson? | select(type == "object" and .id == 1)' 2>/dev/null \ + | head -n1 || true) [ -n "$RESPONSE" ] && break sleep 1 done - docker rm -f "$CID" >/dev/null 2>&1 + cleanup echo "Response: $RESPONSE" - if [ -n "$RESPONSE" ] && echo "$RESPONSE" | jq -e '.result.protocolVersion' > /dev/null 2>&1; then + # agentInfo is optional in ACP, so only the version is asserted. + if [ -n "$RESPONSE" ] && echo "$RESPONSE" | jq -e '.jsonrpc == "2.0" and .result.protocolVersion == 1' > /dev/null 2>&1; then AGENT_NAME=$(echo "$RESPONSE" | jq -r '.result.agentInfo.name // "unknown"') echo "✅ ACP handshake ok — agent=$AGENT_NAME" + elif [ -n "$RESPONSE" ]; then + # The agent answered but rejected initialize (JSON-RPC error) or + # negotiated a different version. Do not hide this behind --help. + echo "❌ ACP initialize was rejected or returned an unexpected protocolVersion" + exit 1 elif [ "${{ matrix.variant.suffix }}" = "-codex" ]; then echo "❌ Codex ACP handshake failed" exit 1 else - echo "⚠️ ACP handshake returned no response — falling back to CLI check" + echo "⚠️ ACP handshake returned no response within 30 s — falling back to CLI check" docker run --rm --entrypoint ${{ matrix.variant.agent }} \ openab-test${{ matrix.variant.suffix }} --help >/dev/null 2>&1 echo "✅ Agent CLI responds (ACP skipped — likely needs auth)" From b827ab6fdcfdb536d0ebb8f3a5ea1eb1c5bd89b3 Mon Sep 17 00:00:00 2001 From: chaodu-agent <274062505+chaodu-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 00:51:33 +0000 Subject: [PATCH 3/3] fix(review): only accept JSON-RPC responses in the ACP probe and fix 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. --- .github/workflows/docker-smoke-test.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-smoke-test.yml b/.github/workflows/docker-smoke-test.yml index 5ab893e4a..3e6c0ca4b 100644 --- a/.github/workflows/docker-smoke-test.yml +++ b/.github/workflows/docker-smoke-test.yml @@ -133,9 +133,8 @@ jobs: - name: Verify agent responds run: | - # ACP v1 requires an integer protocolVersion. A string value is - # rejected with "Invalid params" by strict agents, which then fall - # through to the weaker --help check below. + # ACP v1 requires an integer protocolVersion. Strict agents reject a + # string value with "Invalid params", which now fails the leg below. INIT='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{},"clientInfo":{"name":"ci-test","version":"0.0.1"}}}' CID="" @@ -152,15 +151,17 @@ jobs: trap cleanup EXIT # Start agent in background, send init, and poll for the reply to - # request id 1 instead of a fixed sleep: cold starts vary. Other - # JSON lines (notifications, logs, malformed output) are skipped. + # request id 1 instead of a fixed sleep: cold starts vary. Only a + # JSON-RPC response (result or error) counts; notifications, agent + # requests, logs, and malformed lines are skipped. An error with + # id null (parse error, per JSON-RPC 2.0) also counts. CID=$(docker run -d -i --entrypoint sh openab-test${{ matrix.variant.suffix }} -c 'exec ${{ matrix.variant.agent }} ${{ matrix.variant.agent_args }} 2>/dev/null') echo "$INIT" | docker attach --no-stdin=false "$CID" & ATTACH_PID=$! RESPONSE="" for _ in $(seq 1 30); do RESPONSE=$(docker logs "$CID" 2>/dev/null \ - | jq -R -c 'fromjson? | select(type == "object" and .id == 1)' 2>/dev/null \ + | jq -R -c 'fromjson? | select(type == "object" and .jsonrpc == "2.0" and (has("result") or has("error")) and (.id == 1 or (.id == null and has("error"))))' 2>/dev/null \ | head -n1 || true) [ -n "$RESPONSE" ] && break sleep 1