Files
PaperClipAI/packages
f37252180b fix(openclaw-gateway): keep whitespace on streamed assistant deltas (#14150)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The `openclaw_gateway` adapter streams the agent reply as
`assistant` deltas and joins them into the run summary
> - Each delta goes through `nonEmpty()`, which trims whitespace
> - Deltas carry their word-boundary space (`" blocked"`), so the trim
removes it and words run together
> - The broken text is stored as the issue comment, so users see
corrupted agent replies
> - This pull request keeps each delta verbatim and skips only empty
strings
> - The benefit is that agent comments from the OpenClaw gateway are
stored correctly

## Linked Issues or Issue Description

Fixes #14149

## What Changed

- Add `readAssistantChunk()` in `execute.ts`. It returns a non-empty
string `delta` without a trim. If there is no delta, it falls back to
the trimmed `text` (the old behavior).
- Use `readAssistantChunk()` in the `assistant` stream handler.
- Add unit tests for whitespace-bearing, whitespace-only, empty, and
non-string deltas.

## Verification

- `npx vitest run src/server/execute.test.ts` in
`packages/adapters/openclaw-gateway`: 12 tests pass.
- `npx tsc --noEmit` in the same package: no errors.
- Manual: the same one-line change is applied to a local 2026.916.1
install that showed the bug.

## Risks

Low risk. The change affects only `assistant` deltas. The final
`join("").trim()` still removes outer whitespace from the summary.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: EpaL <358229+EpaL@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Andrew Aymeloglu <aaymeloglu@gmail.com>
2026-11-30 21:40:10 +00:00
..