Files
PaperClipAI/packages
Ray f4baaa4f48 fix(pi-local): respect message roles in transcripts (#11781)
## Thinking Path

> - Paperclip manages AI agents and shows their run transcripts
> - The Pi local adapter converts Pi JSON stdout events into transcript
entries
> - Pi emits `message_end` events for user, assistant, and tool-result
messages
> - The parser marked text from every `message_end` event as assistant
output
> - This made the wake payload look like assistant output and repeated
tool results
> - This pull request maps user messages to user entries and ignores
other non-assistant messages
> - The benefit is correct speaker attribution without a change to
assistant output

## Linked Issues or Issue Description

Fixes: #11780

## What Changed

- Read `message.role` before creating transcript entries.
- Render user messages as user entries.
- Ignore tool-result and unsupported roles in `message_end`.
- Add regression tests for user, assistant, tool-result, and unsupported
roles.

## Verification

- `pnpm exec vitest run
packages/adapters/pi-local/src/ui/parse-stdout.test.ts --config
packages/adapters/pi-local/vitest.config.ts` — 4 tests passed.
- `pnpm --filter @paperclipai/adapter-pi-local typecheck` — passed.
- `pnpm --filter @paperclipai/adapter-pi-local build` — passed.
- `pnpm -r typecheck` — passed.
- `pnpm build` — passed.
- `pnpm test:run` — 4,498 tests passed, 30 failed, and 5 skipped. The
failures are in unrelated server suites on macOS. They cover `/tmp` and
`/private/tmp` path differences, workspace runtime checks, and test port
allocation. The Pi parser regression tests passed again after the full
run.

## Risks

Low risk. This change only affects Pi `message_end` transcript
classification. Assistant text and thinking output stay the same.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

OpenAI Codex with a GPT-5-based model. The session used reasoning, tool
use, and code execution. The exact model ID and context window were not
exposed to the 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 (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] 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
2026-12-04 11:28:21 -08:00
..