Skip to content

Fix dashboard history projection and approval followups - #92328

Closed
Hidetsugu55 wants to merge 1 commit into
openclaw:mainfrom
Hidetsugu55:hide/fix/dashboard-history-followup-clean-20260612
Closed

Hidetsugu55 wants to merge 1 commit into
openclaw:mainfrom
Hidetsugu55:hide/fix/dashboard-history-followup-clean-20260612

Conversation

@Hidetsugu55

@Hidetsugu55 Hidetsugu55 commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes dashboard history projection so toolCall-only assistant messages do not hide recent user context, and suppresses prompt persistence for exec approval follow-up resumes.

This is a clean replacement for #92312 with only the intended minimal diff.

Tests:

  • pnpm exec vitest run --config test/vitest/vitest.gateway.config.ts src/gateway/server-methods/server-methods.test.ts src/gateway/session-history-state.test.ts
  • pnpm exec vitest run --config test/vitest/vitest.agents.config.ts src/agents/bash-tools.exec-approval-followup.test.ts
  • ./node_modules/.bin/oxfmt --check --threads=1 src/gateway/chat-display-projection.ts src/gateway/server-methods/server-methods.test.ts src/agents/bash-tools.exec-approval-followup.ts src/agents/bash-tools.exec-approval-followup.test.ts

Real behavior proof

Behavior or issue addressed: Two operator-dashboard regressions. (1) The most recent user prompt vanished from chat history when the last assistant turn was a toolCall-only message (a read/exec tool call with no visible text): the recency window kept the toolCall-only assistant turn and dropped the user prompt. (2) After an async exec approval completed, the synthetic resume prompt ("An async command the user already approved has completed...") was persisted as a role: "user" message, polluting the visible transcript and model context with a fake user turn.

Real environment tested: A real OpenClaw gateway runtime started from this branch's worktree on macOS (Darwin, Apple Silicon), exercising the genuine gateway server, session store, exec approval manager, and chat-history projection. The model backend is a deterministic local stub HTTP server (no real LLM) so the exec tool call and the approval follow-up fire reproducibly; every other layer is the real runtime path.

Exact steps or command run after this patch: For fix 1, against a normally-started gateway over the operator socket, node openclaw.mjs gateway call agent seeds a turn, then node openclaw.mjs gateway call chat.history with limit: 1 reads it back. At that point the transcript holds exactly two turns (seq 1 user "RUN_PROOF_EXEC now", seq 2 assistant toolCall-only exec), and limit: 1 is the worst case for the bug. For fix 2, a real in-process gateway with an operator client runs client.request("agent", ...), then client.request("exec.approval.resolve", { id, decision: "allow-once" }), then the on-disk session transcript JSONL is read and its roles counted.

Evidence after fix: Fix 1 live chat.history runtime output with limit: 1 returns the user prompt, not the toolCall-only assistant turn:

{
  "sessionKey": "agent:main:main",
  "messages": [
    {
      "role": "user",
      "content": [ { "type": "text", "text": "RUN_PROOF_EXEC now" } ],
      "timestamp": 1781237219317,
      "__openclaw": { "id": "3cd9ea06", "seq": 1 }
    }
  ]
}

Fix 2 live gateway runtime log of the approval cycle, plus the resulting on-disk transcript role breakdown and per-record dump (the exec result reaches the agent as a toolResult and the turn continues, with no second user turn synthesized):

[proof] pending approval: 72b31326-6ffb-4210-bdc1-311f8abb9a1a command: printf 'PROOF_ASYNC_EXEC_OUTPUT\n'
[ws] res ok exec.approval.waitDecision 282ms
[proof] resolved approval: {"ok":true}
[proof] transcript role counts: {"user":1,"assistant":2,"toolResult":1}
[proof] follow-up completion persisted as role=user message? false
[proof] chat.history user-role follow-up messages: 0

4 role=user        text:RUN_PROOF_EXEC now
5 role=assistant    toolCall:exec
6 role=toolResult   text:PROOF_ASYNC_EXEC_OUTPUT
7 role=assistant    text:Standing by.

Observed result after fix: For fix 1, with a limit: 1 recency window the live gateway returns the seq 1 user prompt; before this patch the same query returned only the seq 2 toolCall-only assistant turn and the user prompt disappeared. For fix 2, the async approval completion is delivered to the agent through the toolResult channel (record 6) and the assistant continues the turn (record 7), while the transcript retains a single role: "user" turn (the original prompt) and the "already approved has completed" resume is not written as a user message. The completion payload still reaches model context; only the spurious user-turn persistence is suppressed.

What was not tested: A real third-party LLM was not used (the backend was a deterministic local stub so the tool call and follow-up are reproducible); the projection and persistence code under test is provider-independent. Multi-session and cross-channel delivery variants were covered only by the existing unit suites, not this live run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 12, 2026
@clawsweeper

clawsweeper Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed June 21, 2026, 2:57 PM ET / 18:57 UTC.

Summary
The PR filters recent dashboard chat-history projection around tool-call-only assistant turns and sets exec approval follow-up agent resumes to suppress synthetic prompt persistence.

PR surface: Source +41, Tests +47. Total +88 across 4 files.

Reproducibility: yes. by source inspection rather than an executed failing run: current main slices recent projected history after projection and omits suppressPromptPersistence on exec approval follow-up agent requests. The PR body also supplies after-fix live gateway logs for both fixed paths.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #92328
Summary: This PR is the focused open replacement for an earlier closed, unmerged branch with the same stated dashboard-history and approval-follow-up fixes; the other related PRs are adjacent exec-follow-up history rather than the same remaining work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Resolve the branch conflict against current main while preserving current projector behavior.
  • Extend the recent tool-call-only filter and tests to cover hidden reasoning/redacted thinking blocks.

Risk before merge

  • [P1] GitHub currently reports this branch as CONFLICTING/DIRTY, so it cannot land until the branch is refreshed and the merge result is reviewed.
  • [P2] The conflict resolution needs to preserve current-main chat-display projector changes, including the empty assistant error fallback path that is not present in the PR head snapshot.

Maintainer options:

  1. Decide the mitigation before merge
    Rebase on current main, preserve the current projector behavior, extend recent-display filtering to all hidden reasoning block variants, and land the focused regression coverage with the exec follow-up suppression fix.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] A narrow automated repair can update the PR branch by resolving the current-main conflict and adding the missing hidden-reasoning projection coverage.

Security
Cleared: No concrete security or supply-chain concern was found; the diff changes internal gateway/agent projection, a backend-only session-effect flag, and focused tests.

Review findings

  • [P2] Handle hidden reasoning in recent tool-call rows — src/gateway/chat-display-projection.ts:1619-1620
Review details

Best possible solution:

Rebase on current main, preserve the current projector behavior, extend recent-display filtering to all hidden reasoning block variants, and land the focused regression coverage with the exec follow-up suppression fix.

Do we have a high-confidence way to reproduce the issue?

Yes, by source inspection rather than an executed failing run: current main slices recent projected history after projection and omits suppressPromptPersistence on exec approval follow-up agent requests. The PR body also supplies after-fix live gateway logs for both fixed paths.

Is this the best way to solve the issue?

No, not yet. The approach uses the right shared projector and existing backend-only prompt-suppression contract, but the recent filter should also handle hidden reasoning/redacted thinking blocks and the branch needs a clean rebase before merge.

Full review comments:

  • [P2] Handle hidden reasoning in recent tool-call rows — src/gateway/chat-display-projection.ts:1619-1620
    The new filter only treats thinking blocks as ignorable around tool-call-only assistant turns. A provider transcript with a hidden reasoning or redacted_thinking block plus a tool call still returns false here, so projectRecentChatDisplayMessages(..., { maxMessages: 1 }) can keep the non-visible assistant row and drop the last user prompt. Please treat those hidden reasoning block spellings like thinking and add a regression case.
    Confidence: 0.87

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against edd1d3319cce.

Label changes

Label justifications:

  • P2: This is a bounded gateway/agent bug fix for visible dashboard context and transcript persistence with limited blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (logs): The PR body includes after-fix real gateway runtime logs for both chat.history projection and exec approval transcript persistence, with private details avoided.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix real gateway runtime logs for both chat.history projection and exec approval transcript persistence, with private details avoided.
Evidence reviewed

PR surface:

Source +41, Tests +47. Total +88 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 45 4 +41
Tests 2 48 1 +47
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 93 5 +88

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts src/agents/bash-tools.exec-approval-followup.test.ts -- --reporter=verbose.
  • [P1] ./node_modules/.bin/oxfmt --check --threads=1 src/gateway/chat-display-projection.ts src/gateway/server-methods/server-methods.test.ts src/agents/bash-tools.exec-approval-followup.ts src/agents/bash-tools.exec-approval-followup.test.ts.
  • [P1] git diff --check.

What I checked:

  • Repository policy read: Root AGENTS.md plus scoped src/agents, src/gateway, and src/gateway/server-methods AGENTS.md were read; gateway hot-path and transcript guidance shaped the review scope. (AGENTS.md:1, edd1d3319cce)
  • Current-main chat-history path: chat.history passes recency-filtered transcript rows into projectRecentChatDisplayMessages with maxMessages derived from the requested limit, so the shared projector owns the dashboard recency behavior. (src/gateway/server-methods/chat.ts:2724, edd1d3319cce)
  • Current-main recency bug: Current main projects display messages and then slices the last maxMessages entries, so a trailing non-visible tool-call-only assistant row can consume a one-message window before the user prompt. (src/gateway/chat-display-projection.ts:1737, edd1d3319cce)
  • PR projector change: The PR adds a recent-display filter for assistant rows that contain toolCall/toolUse blocks with no visible text, plus a regression test for the maxMessages:1 user-context case. (src/gateway/chat-display-projection.ts:1598, 1c411dc6cc49)
  • Hidden-reasoning gap: The new filter ignores thinking blocks but not other hidden reasoning block spellings, while current projector code already treats reasoning/redacted_thinking as hidden in display sanitization paths. (src/gateway/chat-display-projection.ts:1619, 1c411dc6cc49)
  • Current-main follow-up persistence gap: buildAgentFollowupArgs currently builds the synthetic exec approval follow-up agent request without suppressPromptPersistence, while gateway already has a backend-only suppression contract. (src/agents/bash-tools.exec-approval-followup.ts:270, edd1d3319cce)

Likely related people:

  • 849261680: GitHub commit metadata links this handle to 932d6ea, which changed chat-display projection and adjacent server-method tests for sessions_send display projection. (role: recent chat-history projection contributor; confidence: medium; commits: 932d6ea8e5ce; files: src/gateway/chat-display-projection.ts, src/gateway/server-methods/server-methods.test.ts)
  • openperf: GitHub commit metadata links this handle to 2ffbea2, which changed exec approval follow-up handling and gateway stale-follow-up behavior. (role: recent exec approval follow-up contributor; confidence: high; commits: 2ffbea20d2f6; files: src/agents/bash-tools.exec-approval-followup.ts, src/agents/bash-tools.exec-approval-followup.test.ts, src/gateway/server-methods/agent.ts)
  • hclsys: This handle authored merged PR fix(exec): preserve turnSourceChannel as messageProvider in approval followup runs #74666, which changed buildAgentFollowupArgs, the helper this PR touches. (role: adjacent exec follow-up contributor; confidence: high; commits: 2de6ad45445a; files: src/agents/bash-tools.exec-approval-followup.ts, src/agents/bash-tools.exec-approval-followup.test.ts)
  • udaymanish6: This handle authored merged PR fix(gateway): dedupe exec followup continuations #82717, which worked across exec follow-up continuation and the same gateway agent path. (role: adjacent gateway follow-up contributor; confidence: medium; commits: 91f45d9c8a10; files: src/agents/bash-tools.exec-approval-followup.ts, src/agents/bash-tools.exec-approval-followup.test.ts, src/gateway/server-methods/agent.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label Jun 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 12, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 11, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant