Summary
apply_samples.cjs crashes with SyntaxError: Unexpected token 'd', "[debug] Exe"... is not valid JSON while replaying a sample for the create_pull_request safe-output tool. The crash terminates the agent step with exit code 1.
Root cause: sendJsonRpc (apply_samples.cjs:178) assumes the MCP server's stdout contains only JSON-RPC frames, but the safe-outputs MCP server interleaves [debug] … lines on stdout when generating a PR patch/bundle.
Reproduction
Workflow test-copilot-create-pull-request in githubnext/gh-aw-test compiled with --use-samples; sample replays a single create_pull_request call. Trigger via gh aw run test-copilot-create-pull-request.
Observed
Failing run: https://github.com/githubnext/gh-aw-test/actions/runs/27076897189
Truncated log:
[safeoutputs] Pinned branch 'gh-aw-sample-copilot-multi-commit' to SHA …
[safeoutputs] Generating patch for create_pull_request with branch: …
[error] Git command failed: git show-ref --verify --quiet refs/remotes/origin/gh-aw-sample-copilot-multi-commit
[error] Exit status: 1
[safeoutputs] Bundle generated successfully: /tmp/gh-aw/aw-gh-aw-sample-copilot-multi-commit.bundle (572 bytes)
[safeoutputs] send: {"jsonrpc":"2.0","id":2,"result":{…,"isError":false}}
[error] SyntaxError: Unexpected token 'd', "[debug] Exe"... is not valid JSON
at JSON.parse (<anonymous>)
at sendJsonRpc (/home/runner/work/_temp/gh-aw/actions/apply_samples.cjs:178:15)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async main (/home/runner/work/_temp/gh-aw/actions/apply_samples.cjs:303:23)
##[error]Process completed with exit code 1.
The [debug] Executing… line is emitted by the MCP server's git/patch code path on stdout instead of stderr, and the apply_samples client tries to JSON.parse it.
Impact
Blocks all sample-based testing of:
test-copilot-create-pull-request (+ nosandbox, siderepo variants)
test-copilot-create-two-pull-requests (+ variants)
test-copilot-push-to-pull-request-branch (+ variants)
test-claude-* and test-codex-* PR-creating equivalents
i.e. ~9 e2e tests in githubnext/gh-aw-test cannot pass with --use-samples until this is fixed.
Suggested fix
Either:
- Route all non-JSON-RPC logging from the safe-outputs MCP server (debug, git command echo, patch progress) to stderr only, so the JSON-RPC parser on stdout never sees it.
- Make
sendJsonRpc line-aware: split on \n and only JSON.parse lines that begin with {.
(1) is the cleaner fix; (2) is defensive.
Environment
- gh-aw
main (commit d25afa6 as of 2026-06-06)
- Hosted runner ubuntu-24.04
- Compiled with
--use-samples
Summary
apply_samples.cjscrashes withSyntaxError: Unexpected token 'd', "[debug] Exe"... is not valid JSONwhile replaying a sample for thecreate_pull_requestsafe-output tool. The crash terminates the agent step withexit code 1.Root cause:
sendJsonRpc(apply_samples.cjs:178) assumes the MCP server's stdout contains only JSON-RPC frames, but the safe-outputs MCP server interleaves[debug] …lines on stdout when generating a PR patch/bundle.Reproduction
Workflow
test-copilot-create-pull-requestingithubnext/gh-aw-testcompiled with--use-samples; sample replays a singlecreate_pull_requestcall. Trigger viagh aw run test-copilot-create-pull-request.Observed
Failing run: https://github.com/githubnext/gh-aw-test/actions/runs/27076897189
Truncated log:
The
[debug] Executing…line is emitted by the MCP server's git/patch code path on stdout instead of stderr, and the apply_samples client tries toJSON.parseit.Impact
Blocks all sample-based testing of:
test-copilot-create-pull-request(+nosandbox,siderepovariants)test-copilot-create-two-pull-requests(+ variants)test-copilot-push-to-pull-request-branch(+ variants)test-claude-*andtest-codex-*PR-creating equivalentsi.e. ~9 e2e tests in
githubnext/gh-aw-testcannot pass with--use-samplesuntil this is fixed.Suggested fix
Either:
sendJsonRpcline-aware: split on\nand onlyJSON.parselines that begin with{.(1) is the cleaner fix; (2) is defensive.
Environment
main(commitd25afa6as of 2026-06-06)--use-samples