mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 01:24:30 +01:00
# fix(openclaw-gateway): show thinking and tool steps in the run transcript ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The OpenClaw gateway adapter runs agents on a remote OpenClaw gateway and streams the agent events into the run log > - The run transcript in the UI shows thinking and tool calls for the built-in adapters, for example `claude_local` and `codex_local` > - For `openclaw_gateway`, the UI parser shows only `assistant` text and errors. It drops `thinking` events and tool `item` events, but the run log has them > - So a board operator cannot see what an OpenClaw agent thinks or which tools it calls while the run is live. A slow or stuck run looks like "Working" with no detail > - This pull request maps these two event streams to the transcript entries that the UI already renders > - The benefit is the same transcript detail for OpenClaw agents as for the built-in adapters, with no server change ## Linked Issues or Issue Description Refs #1639 (OpenClaw gateway transcript output). Related open PRs change the `assistant` branch of the same parser: #13665, #14150, #14217, #4793. This PR does not change that branch. It adds two new branches. **What existing behavior does this improve?** The run transcript of an `openclaw_gateway` agent. **Subsystem affected** Adapters: `packages/adapters/openclaw-gateway/src/ui/parse-stdout.ts`. **Current behavior** `parseAgentEventLine` returns transcript entries only for the `assistant`, `error` and `lifecycle` streams. For `stream=thinking` and `stream=item` it returns an empty list, so the UI shows nothing for them. **Proposed behavior** `stream=thinking` becomes a `thinking` entry (the `delta` text with `delta: true`, or the full `text`). A tool `item` with `phase: "start"` becomes a `tool_call` entry. A tool `item` with `phase: "end"` becomes a `tool_result` entry. A result with a status other than `completed` is an error. **Reason and benefit** Operators can see what an OpenClaw agent does during a run, as they can for the built-in adapters. **Breaking changes** None. Only the UI parser changes. The stored run log does not change. ## What Changed - `parseAgentEventLine` maps `stream=thinking` to `thinking` entries. It keeps streamed deltas, which `appendTranscriptEntry` already joins. - `parseAgentEventLine` maps tool `item` events (`kind: "tool"`) to `tool_call` (start) and `tool_result` (end) entries. The OpenClaw event has the tool name and a title, but not the tool input or output. The entry uses the title as the input and as the result content, and the errortext for a failed tool. - New `parse-stdout.test.ts` with cases for thinking, tool start, tool end (completed and failed), and the streams that stay ignored. ## Verification - `vitest run` on `packages/adapters/openclaw-gateway/src/ui/parse-stdout.test.ts`: 6 tests pass. - Manual: the same mapping on a 2026.1012.0 instance with OpenClaw 2026.9.33 agents. The run transcript shows the thinking and each tool stepduring the run. - Not run: the full repository type check. ## Risks Low risk. The change adds two branches to a UI parser. The events that were shown before have the same result. A thinking stream can be long,so the transcript of an OpenClaw run gets longer, as it is for the built-in adapters. ## Model Used Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution, in Claude Code. ## 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 - [x] I have updated relevant documentation to reflect my changes - [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 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>