Jazzen Chen e944ceddea fix: tolerate missing text in streamed thinking chunks (#852)
## Summary

This makes streamed text/thinking chunk handling defensive when gateways
emit empty or malformed delta payloads.

- Guard `text_delta.text` and `thinking_delta.thinking` before reading
`.length`
- Skip missing/non-string text or thinking content the same way empty
chunks are already skipped
- Add regression coverage for a missing `thinking` delta before a real
text delta
- Add direct `toAcpNotifications` coverage for missing/non-string text
and thinking chunks

## Why

The adapter already skips empty thinking chunks, but some
Anthropic-compatible gateways can emit signature-only or omitted
thinking deltas where `thinking` is absent rather than an empty string.
In that case the adapter currently throws:

```text
Cannot read properties of undefined (reading 'length')
```

That aborts the ACP session even though the following text chunks are
valid.

This change keeps the existing behavior for valid chunks, while treating
missing/non-string chunk text as empty content.

## Test Plan

- `npm run check`
- `npm test -- --run`
- `npm run build`

Also verified manually through a VibeAround Web Chat flow using Claude
Code ACP with an Anthropic-compatible custom endpoint; the session
completed and returned a normal assistant response.

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-07-08 11:23:13 +00:00
2025-09-02 19:06:32 -03:00
2026-03-26 12:19:06 +01:00
2026-03-26 12:19:06 +01:00

ACP adapter for the Claude Agent SDK

npm

Use Claude Agent SDK from ACP-compatible clients!

This tool implements an ACP agent by using the official Claude Agent SDK, supporting:

  • Context @-mentions
  • Images
  • Tool calls (with permission requests)
  • Following
  • Edit review
  • TODO lists
  • Interactive (and background) terminals
  • Custom Slash commands
  • Client MCP servers

Learn more about the Agent Client Protocol.

Contribution Policy

This project does not require a Contributor License Agreement (CLA). Instead, contributions are accepted under the following terms:

By contributing to this project, you agree that your contributions will be licensed under the Apache License, Version 2.0. You affirm that you have the legal right to submit your work, that you are not including code you do not have rights to, and that you understand contributions are made without requiring a Contributor License Agreement (CLA).

Description
Pull mirror of agentclientprotocol/claude-agent-acp (Apache-2.0): the ACP bridge that lets Buzz drive Claude Code
Readme 107 MiB
Languages
TypeScript 99.2%
JavaScript 0.6%
Shell 0.2%