Skip to content

fix(agents): return the full sessions_send reply past the terminal snapshot bound - #175685

Merged
steipete merged 5 commits into
openclaw:mainfrom
wr-web:fix/sessions-send-full-reply
Oct 18, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
wr-web:fix/sessions-send-full-reply

Conversation

@wr-web

@wr-web wr-web commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #175597. This fixes inline replies from waiting sessions_send calls. Delayed inter-session delivery still uses the bounded lifecycle preview and remains a follow-up.

What Problem This Solves

Fixes: a waiting sessions_send silently returned only the first 4,096 characters of a target's long final reply.

User Impact

Waiting callers receive the accepted run's full stored reply. If it cannot be recovered, the result preserves the preview and reports replyTruncated: true with recovery guidance. The normal tool-result size policy still applies; its notice directs callers to request the missing section or a file without repeating the original task. sessions_history also caps individual messages, so it is not advertised as guaranteed tail recovery.

Why This Change Was Made

The terminal snapshot is deliberately bounded lifecycle evidence. The inline reply owner now reuses readLatestAssistantReply, filtered by the accepted run ID, and verifies the existing sanitizer produces the same snapshot before replacing the preview. This avoids selecting a later run's answer. The strict output schema includes the new optional fields.

Maintainer cleanup removes the extra truncation predicate and complete-reply wrapper, reuses the canonical sanitizer, and consolidates duplicate helper tests at the tool boundary. The known ClawSweeper P2 whitespace finding remains covered: a truncated preview can be shorter than 4,096 characters. No detached/background side effects are added or changed.

Original fix by @wr-web; maintainer cleanup by @steipete. Contributor credit is retained in Git history and a Co-authored-by trailer.

Evidence

  • Exact-head CI passed on b32a3bed887a529a55b006d070ee0880ac9c7c11: run 39171063355, 43 successful jobs, no failures; openclaw/ci-gate is green. This covers the changed agent-tool tests, affected consumers, production/test types, lint, docs, prompt snapshots, and repository checks. No CI retry or follow-up push was needed.
  • sessions-send-policy.test.ts: returns the accepted run's full $name with explicit tool-budget truncation covers long replies, whitespace-shortened previews, literal ellipses, a later unrelated run, and the existing 16,000-character tool-result cap. reports a truncated preview when the accepted run's full reply is unavailable checks explicit disclosure and the strict result schema.
  • Changed-file oxlint: seven TypeScript files, 231 rules, zero diagnostics. Used the unchanged core rules with the unrelated UI-only Solid override omitted because the supplied dependencies lack its plugin. oxfmt and git diff --check passed.
  • ClawSweeper exact-head review: no code findings; previous whitespace finding resolved. Its live-proof-only request is excluded by the explicit maintainer proof policy; PR CI is the proof gate.
  • Independent Codex autoreview: scoped-clean, no actionable P0–P2 findings in the candidate. Source/history review confirms the defect on current main. Review was source-only; the accepted-run reader, terminal sanitizer, and delayed path were inspected directly.
  • Live Gateway proof, leases, local tests, negative controls, and local typechecks were intentionally skipped per maintainer policy. No lease or Gateway was started. CI job checks-node-changed-3 passed all 21 tests in sessions-send-policy.test.ts: 7.66 s Vitest duration / 9.13 s including the runner. The five new cases took 27/55/62/50/20 ms (214 ms total). No timers, sleeps, new workers, or live processes were added.

LOC against the merged main base: production +67/-16 (net +51), tests +108/-0, docs +8/-0. Compared with the contributor revision, cleanup removes 40 net lines. Net production growth is retained for exact-run recovery, explicit failure/budget notices, and schema support; unrelated deletions would obscure the fix.

…apshot bound

A waiting sessions_send returned the run's terminal reply snapshot, which is bounded to 4,096 characters, so long peer replies were cut with no signal. When the reply sits at the bound, read the accepted run's own stored reply by run id; if that is unavailable, keep the bounded text and report replyTruncated with a pointer to sessions_history.
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Recover complete waiting sessions_send replies and explicitly disclose unavailable or budget-truncated output.

Example: A target returns 5,000 letter a characters followed by TAIL.

  • Before: The requester receives 4,095 characters and an ellipsis without a completeness warning.
  • After: The requester receives the stored answer including TAIL, or an explicit truncation notice if recovery fails.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Source review found a focused, useful partial repair with no actionable code findings, but the required shipped-entry-point evidence is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Requesting agents receive successful-looking answers with silently omitted content after character 4,096.
Reason: The documented reply contract and reported content loss justify the repair; the maintainer's recorded inline-only direction supports this bounded scope.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR addresses a current inline-reply bug, preserves bounded lifecycle evidence, and fixes the previous whitespace finding.

Priority: P1
Reviewed head: b32a3bed887a529a55b006d070ee0880ac9c7c11

Before merge

  • Add real behavior proof - The changed inline completion owner is exercised with mocked agent.wait and chat.history responses, while the body and re-review comment explicitly state that live Gateway proof was skipped; provide redacted terminal output, logs or a recording of the changed waiting-send behavior through a real Gateway, removing IPs, API keys, phone numbers and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Missing is a real Gateway waiting sessions_send showing a reply tail beyond 4,096 characters, whitespace-shortened preview recovery and budget disclosure; base-red/head-green execution is also unreported.
Agent review details

How this fits together

The sessions_send completion path converts an accepted target run's terminal result into requester-visible tool output, using Gateway history readers to recover long answers.

flowchart LR
  A[Requesting agent] --> B[sessions_send]
  B --> C[Accepted target run]
  C --> D[Bounded terminal preview]
  D --> E[Inline reply owner]
  E --> F[Run filtered stored answer]
  F --> G[Tool result budget]
  G --> A
Loading

Technical review

Best possible solution:

Retain this focused inline repair and track complete delayed delivery in #175597.

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

The bounded terminal producer and current-main inline consumer establish the failure path, consistent with the linked report's observation on OpenClaw 2026.10.3; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch is a focused inline repair: it reuses existing recovery and sanitization owners, preserves lifecycle bounds, and discloses recovery failure without repeating the target task.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7310bf167db7.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit fa70549 adds src/agents/run-wait.ts:175 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fa70549fe460; files: src/agents/run-wait.ts)
  • Jay Zhou: Raw commit ebf4bd7 adds src/agents/run-wait.ts:170 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ebf4bd70ca7a; files: src/agents/run-wait.ts)
  • marchpure: Raw commit b85147f adds src/agents/pi-embedded-runner/context-truncation-notice.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: b85147ff7615; files: src/agents/pi-embedded-runner/context-truncation-notice.ts)

PR surface

Source +51, Tests +108, Docs +8. Total +167 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 67 16 +51
Tests 1 108 0 +108
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 183 16 +167

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +67/-16; tests +108/-0 Growth serves accepted-run recovery, explicit fallback disclosure, budget guidance and output-schema coverage without adding another state owner.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: A reported, source-confirmed agent coordination workflow silently loses the tail of long replies on current main.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-17T16:39:30.194Z sha 1a20d45 :: needs changes before merge. :: [P2] Detect truncation without assuming a 64-character whitespace limit

Reviewed October 18, 2026, 6:18 PM ET / 22:18 UTC (Revision 2).

…ngth

Truncation trims the whole retained prefix before its marker, so a cut reply can be far shorter than the bound (4,000 characters + 100 spaces + TAIL becomes 4,000 characters + marker). Treat any reply ending in the marker as possibly cut and let the accepted run's stored reply decide: it extends the prefix (recover it) or equals it (a reply that really ends in an ellipsis).
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Oct 17, 2026
steipete and others added 3 commits October 18, 2026 14:57
Reuse the existing run-filtered reply reader and canonical snapshot sanitizer,
remove the extra recovery helpers, and disclose unavailable or budget-limited
reply text without suggesting that the original task be repeated. Keep the
strict output schema and session-tool docs consistent with the result.

Related: openclaw#175597
Original fix by @wr-web; maintainer cleanup preserves the inline-only scope.

Co-authored-by: Wang Rui <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Head b32a3bed887a529a55b006d070ee0880ac9c7c11 retains the whitespace-truncation fix, removes the extra helper layer, verifies the accepted run's stored reply with the canonical sanitizer, and adds explicit fallback/budget guidance plus schema coverage. The body remains Related: #175597 because delayed delivery is a follow-up.

Changed-file lint/format and independent Codex autoreview passed. PR CI is the proof gate per maintainer policy; live proof was intentionally skipped. Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/39171063355

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S and removed size: M labels Oct 18, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@steipete

Copy link
Copy Markdown
Contributor

ClawSweeper's exact-head review reports no code findings and confirms the earlier whitespace-truncation finding is resolved.

The remaining live-Gateway/base-red proof request is intentionally not followed: the maintainer proof policy for this campaign selects exact-head PR CI as the test gate and explicitly excludes live Gateway runs, leases, and local negative controls/typechecks. PR CI is the proof per maintainer policy. The selected Node and UI test shards have passed; remaining type/lint jobs are tracked in https://github.com/openclaw/openclaw/actions/runs/39171063355.

The PR continues to say Related: #175597, with delayed delivery documented as a follow-up. No additional code finding or scope decision is pending.

@steipete
steipete merged commit b3c8f8a into openclaw:main Oct 18, 2026
155 of 160 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…apshot bound (openclaw#175685)

* fix(agents): return the full sessions_send reply past the terminal snapshot bound

A waiting sessions_send returned the run's terminal reply snapshot, which is bounded to 4,096 characters, so long peer replies were cut with no signal. When the reply sits at the bound, read the accepted run's own stored reply by run id; if that is unavailable, keep the bounded text and report replyTruncated with a pointer to sessions_history.

* fix(agents): detect truncated sessions_send replies by marker, not length

Truncation trims the whole retained prefix before its marker, so a cut reply can be far shorter than the bound (4,000 characters + 100 spaces + TAIL becomes 4,000 characters + marker). Treat any reply ending in the marker as possibly cut and let the accepted run's stored reply decide: it extends the prefix (recover it) or equals it (a reply that really ends in an ellipsis).

* fix(agents): recover complete inline session replies

Reuse the existing run-filtered reply reader and canonical snapshot sanitizer,
remove the extra recovery helpers, and disclose unavailable or budget-limited
reply text without suggesting that the original task be repeated. Keep the
strict output schema and session-tool docs consistent with the result.

Related: openclaw#175597
Original fix by @wr-web; maintainer cleanup preserves the inline-only scope.

Co-authored-by: Wang Rui <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Wang Rui <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…cters (#178271)

* fix(agents): delayed sessions_send replies are cut off at 4,096 characters

Recover accepted-run answers before delayed delivery and keep truncation guidance in requester instructions, not source-channel messages.

Related: #175597

* docs: note that delayed sessions_send replies are recovered too

* fix(agents): keep full delayed sessions_send replies after the sender's turn ends

Read matched full replies from the accepted run's retained Gateway result. Keep inline history recovery and bounded lifecycle previews unchanged.

Related: #175597

* refactor(agents): simplify retained reply recovery

* fix(agents): recheck accepted reply authority before reading the retained answer

Validate current accepted endpoint incarnations and live completion custody before reading full retained results. Preserve accepted replies after send-policy withdrawal.

* fix(agents): keep the Gateway run tracker out of sessions_send tool loading

The accepted-reply reader statically imported agent-dedupe, which loads the
agent-job tracker and registers its lifecycle listener when the tool module
loads. Tool loading must not start Gateway run tracking, so the reader now
loads it only when a live in-process Gateway reaches that path, and rechecks
delivery authority after the import.

Explain the isolated unit-test mocks and keep the logging mock's real exports.

Co-authored-by: RJ <[email protected]>
Release adaptation: combined with its prerequisite #175685 (inline
sessions_send recovery), which is not on the stable line. The stable line
keeps the inline wait in sessions-send-tool.ts, so its terminal branch moves
into settleSessionsSendReply in sessions-send-helpers.ts (keeping
sessions-send-tool.ts under its line cap) and uses resolveSessionsSendReply;
the delayed A2A flow keeps its non-deliverable reply filter and relies on
waitForAgentRunReply only exposing visible replies. The stable line has
sanitizeAgentRunTerminalReplyText (string) instead of the snapshot-returning
sanitizer, so the comparison and test fixtures use it. The requester
reply-flow test file does not exist on this line; the A2A, policy, and
dispatch-owner tests cover the change.

----
fix(agents): return the full sessions_send reply past the terminal snapshot bound (#175685)

* fix(agents): return the full sessions_send reply past the terminal snapshot bound

A waiting sessions_send returned the run's terminal reply snapshot, which is bounded to 4,096 characters, so long peer replies were cut with no signal. When the reply sits at the bound, read the accepted run's own stored reply by run id; if that is unavailable, keep the bounded text and report replyTruncated with a pointer to sessions_history.

* fix(agents): detect truncated sessions_send replies by marker, not length

Truncation trims the whole retained prefix before its marker, so a cut reply can be far shorter than the bound (4,000 characters + 100 spaces + TAIL becomes 4,000 characters + marker). Treat any reply ending in the marker as possibly cut and let the accepted run's stored reply decide: it extends the prefix (recover it) or equals it (a reply that really ends in an ellipsis).

* fix(agents): recover complete inline session replies

Reuse the existing run-filtered reply reader and canonical snapshot sanitizer,
remove the extra recovery helpers, and disclose unavailable or budget-limited
reply text without suggesting that the original task be repeated. Keep the
strict output schema and session-tool docs consistent with the result.

Related: #175597
Original fix by @wr-web; maintainer cleanup preserves the inline-only scope.

Co-authored-by: Wang Rui <[email protected]>

(cherry picked from commit b3c8f8a)
(cherry picked from commit 7bd6895)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants