Skip to content

fix: fixes an ACP interoperability issue when OpenCode is used with the Agent Client Protocol Python SDK over stdio #17017

Open
zztdandan wants to merge 2 commits intoanomalyco:devfrom
zztdandan:bugfix/acp-bugfix
Open

fix: fixes an ACP interoperability issue when OpenCode is used with the Agent Client Protocol Python SDK over stdio #17017
zztdandan wants to merge 2 commits intoanomalyco:devfrom
zztdandan:bugfix/acp-bugfix

Conversation

@zztdandan
Copy link
Copy Markdown

@zztdandan zztdandan commented Mar 11, 2026

Issue for this PR

Fixes #17019

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR fixes an ACP interoperability issue when OpenCode is used with the Agent Client Protocol Python SDK over stdio.

In this integration mode, JSON-RPC payload size is effectively constrained (observed around the 64KB boundary in practice for this path). When a single emitted JSON message exceeds this boundary, the Python SDK side can hit a fatal error on the stdio channel/port handling path, which can break ACP communication for the client session.

OpenCode tool updates can easily exceed that limit:

  • rawOutput.output is often very large.
  • tool_call_update.content[].content.text can also become large (for example, read on moderately large files).

To prevent oversized ACP messages from causing fatal stdio-side failures and breaking delivery, this change applies field-level truncation for those two high-risk text fields before sending tool_call_update payloads to ACP.

What changed:

  • Added sanitization in ACP update sending for tool_call_update payloads.
  • Capped each risky text field at 10KB (UTF-8 byte-based limit).
  • Appended an explicit truncation notice to preserve operator visibility (including omitted byte count).
  • Added clear English inline comments documenting why and where truncation is applied.

Why this works:

  • It keeps update payloads comfortably below transport-boundary risk while preserving useful context for ACP consumers.
  • In IDE usage, ACP users typically do not inspect full raw tool output in these update frames, so truncating very large payload text is a practical tradeoff for transport reliability.
  • It addresses the observed failure mode directly at the emission boundary before oversized text reaches stdio transport.

Scope of truncation (only):

  1. update.content[].content.text
  2. update.rawOutput.output

No other ACP update types are altered.

Notes:

  • This is a transport-safety and robustness fix.
  • It does not change tool execution semantics.
  • It only limits oversized text payload segments before ACP emission.

How did you verify your code works?

I validated this change with:

  • Targeted ACP tests
  • Type checks
  • Build checks
  • Local runtime verification

After this change, the ACP Python SDK can reliably receive previously oversized tool-update messages in truncated form.

Screenshots / recordings

N/A (non-UI change).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Mar 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP stdio transport crashes on oversized tool_call_update payloads (truncate large text fields)

1 participant