Files
PaperClipAI/packages/adapters
Huanyi Xie 3b24911c16 fix(hermes-gateway): preserve complete whitespace-sensitive delta frames (#15201)
## Thinking Path

> - Paperclip shows agent output in a live transcript.
> - Hermes Gateway emits structured events and raw message text to
stdout.
> - A raw chunk without a newline prefixes the next structured event.
> - The anchored transcript parser then loses later message deltas.
> - This pull request emits each delta once as a complete JSON event.
> - The transcript can read all streamed events again.

## Linked Issues or Issue Description

Fixes: #15132


Related PR #9909 removes the duplicate raw-delta log write. This PR also
fixes two separate fidelity defects that its diff leaves:
whitespace-only/leading/trailing delta text is trimmed by `nonEmpty`,
and large delta payloads are shortened by the event-log summarizer. The
final implementation preserves the exact delta in a JSON frame and the
assembled output, with whitespace, 9,000-character, and forged-prefix
regressions. The overlapping raw-log removal is required so the safe
frame is the only transcript copy.

## What Changed

- Remove the redundant raw stdout write; each delta is logged once as a
JSON event.
- Preserve whitespace and existing secret redaction; keep complete
message deltas beyond the diagnostic truncation limit.
- Exercise the persisted stdout through the real transcript parser, with
consecutive chunks, embedded newlines, a forged event prefix, and a
9,000-character delta.

## Verification

- The new regression finds only the first delta on the original code.
- All 87 Hermes adapter tests pass after the fix.
- Hermes adapter typecheck and build pass.
- git diff --check passes.
- All remote full-repository CI gates pass for the final head.

## Risks

Low risk. Message-delta logs contain one canonical redacted delta
payload. Other events keep their existing diagnostic limits. The
regression proves there are no duplicate stdout entries or fabricated
events.

## Model Used

OpenAI Codex, based on GPT-6, assisted with source review,
implementation and local test execution. The exact deployment model ID
and context-window size are not exposed in this session.

## 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 and contains no internal
Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass (targeted local checks and
full remote CI pass)
- [x] I have added or updated tests where applicable (Hermes regression
/ real Compose interpolation checks)
- [x] I have updated relevant documentation to reflect my changes
(Hermes has no configuration changes; Compose documentation is updated)
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-11-02 15:07:44 -06:00
..