microsoft / microsoft/agent-governance-toolkit

[Bug] OpenCode and Antigravity emit Content-Length frames; Antigravity cannot read NDJSON

Open
#4,012 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-review:HIGH triage
Dominant language
Python
Stars
6.3k
Forks
1.1k
Avg merge
5d 11h
Merged PRs (30d)
142

Description

Package

Other

Description

Affected packages: @microsoft/agent-governance-opencode 5.0.0 and @microsoft/agent-governance-antigravity-cli 5.0.0.

The MCP stdio transport specifies newline-delimited JSON, but both bundled servers write responses using LSP-style Content-Length framing:

  • OpenCode: agent-governance-opencode/server/agt-mcp.mjs:116.
  • Antigravity: agent-governance-antigravity-cli/assets/extensions/agt-global-policy/mcp/server.mjs:295.

OpenCode accepts both newline-delimited JSON and Content-Length-framed input, but its responses are not newline-delimited JSON. Antigravity's drainInputBuffer waits for \r\n\r\n before processing a request (mcp/server.mjs:52–67), so newline-delimited requests are never processed. In the Antigravity runtime check, a newline-delimited initialize request produced no output and the process exited with status 0 on EOF; the same request with Content-Length framing received a Content-Length-framed response.

A spec-conformant MCP client therefore cannot complete initialization with either server. Antigravity also cannot process subsequent newline-delimited requests. This prevents access to their tools and to server/discover, which landed in #3642; #3642 did not introduce the framing defect.

imran-siddique identified this in the review of #3642:
https://github.com/microsoft/agent-governance-toolkit/pull/3642#pullrequestreview-5098013134

The claude-code server has the same write-side defect, but its fix is covered by #3833 and is outside this issue's scope.

The planned follow-up is one PR covering OpenCode's write path and both Antigravity transport directions, within the boundary described in the proposed ADR-0027. That PR will follow #3833 so transport and discovery can be tested together.

How does this impact your work?

End-to-end use of these two servers is blocked for spec-conformant MCP clients: initialization cannot complete, so their governance and policy tools cannot be reached. The workaround is a client that supports LSP-style Content-Length framing.

Timeline

No hard deadline. The fix PR is planned after #3833 lands.

Steps to Reproduce
  1. Clone the repository and check out the revision used for verification:

    git clone https://github.com/microsoft/agent-governance-toolkit.git
    cd agent-governance-toolkit
    git checkout c63c51e
    
  2. Send Antigravity a newline-delimited initialize request:

    request='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2026-07-28","capabilities":{},"clientInfo":{"name":"probe","version":"0"}}}'
    printf '%s\n' "$request" |
      node agent-governance-antigravity-cli/assets/extensions/agt-global-policy/mcp/server.mjs
    

    Observed: no output; the server exits with status 0 on EOF without processing the request.

    Expected: the server processes the request and writes a newline-delimited JSON response.

  3. Send the same request using Content-Length framing:

    length=$(node -e 'process.stdout.write(String(Buffer.byteLength(process.argv[1], "utf8")))' "$request")
    printf 'Content-Length: %s\r\n\r\n%s' "$length" "$request" |
      node agent-governance-antigravity-cli/assets/extensions/agt-global-policy/mcp/server.mjs
    

    Observed: the server responds, but the response also uses Content-Length framing.

  4. Inspect OpenCode's transport implementation:

    • agent-governance-opencode/server/agt-mcp.mjs:116 serializes responses as Content-Length: ${Buffer.byteLength(body, "utf8")}\r\n\r\n${body}.
    • Its reader supports both Content-Length frames and newline-delimited JSON, as documented in agent-governance-opencode/README.md:64.

    OpenCode was verified by source inspection only; its runtime reproduction was not run.

Environment
  • OS: macOS 26.6.2 (Darwin 25.6)
  • Node.js: v26.3.0
  • Repository revision: c63c51e on main (2026-09-15)
  • OpenCode package: @microsoft/agent-governance-opencode 5.0.0
  • Antigravity package: @microsoft/agent-governance-antigravity-cli 5.0.0
  • Declared Node.js requirements: OpenCode >=22.0.0; Antigravity >=20.19.0
  • Verification: Antigravity runtime checks and OpenCode source inspection
Logs / Error Output
Antigravity — newline-delimited initialize request:
(no stdout output; process exits with status 0 on EOF)

Antigravity — the same initialize request with Content-Length framing:
Content-Length: 154

{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"agt-global-policy","version":"3.3.0"}}}
Code of Conduct
  • I agree to follow the Microsoft Open Source Code of Conduct

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with agent-governance-opencode/server/agt-mcp.mjs:116 and agent-governance-antigravity-cli/assets/extensions/agt-global-policy/mcp/server.mjs:52–67, 295; run the provided Antigravity initialize probes at revision c63c51e. Trace both read and write paths, then verify that newline-delimited MCP requests receive newline-delimited responses for initialization and later requests, including server/discover.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.