Repository navigation
fix: answer after tool-only turns when a context engine omits message timestamps - #201766
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR uses a fixed timestamp for temporary finalization bookkeeping so context-engine messages without valid timestamps cannot prevent an answer. Example: A context engine supplies a summary message without a timestamp, and a sessions_send target runs exec before returning NO_REPLY.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness✅ Ready for maintainer review This PR fixes a confirmed final-answer failure still present on main, with no actionable patch defects found; the CI gate remains blocked after WebKit dependency installation failed before browser tests ran. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe embedded runner takes the settled context-engine message view, bounds it using the shared context selector, and passes the resulting messages to isolated final-answer generation. flowchart LR
A[Settled tool turn] --> B[Selected context messages]
B --> C[Temporary selection entries]
C --> D[Shared context selector]
D --> E[Tool-free model request]
E --> F[Final answer]
Technical reviewBest possible solution: Keep the fixed timestamp inside the existing temporary-entry adapter while preserving selected messages, context limits and transcript ownership. Do we have a high-confidence way to reproduce the issue? The current-main conversion deterministically throws for undefined or NaN message timestamps, and the PR supplies matching base-versus-head Gateway output; this read-only review ran no target code. Is this the best way to solve the issue? This is the smallest complete repair: replace irrelevant temporary metadata at its consumer rather than modifying context-engine messages or model-visible timestamps. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4c11507996d1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +44. Total +47 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 19, 2026, 5:31 AM ET / 10:31 UTC. |
|
Merged via squash.
|
…1766) (cherry picked from commit 9156690) Release adaptation: Keep the stable full-prefix test. Exercise in-budget and omitted tool results using stable’s 16 MiB cap; stable no longer sizes this context from contextTokenBudget. Companion audit: #204028, #203901, #202306 and #203536 are separate finalizer-budget, custody, project-transfer and context-window changes; not dependencies of the timestamp guard. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Sometimes an agent runs a tool and then ends its turn without a final answer. A typical case is a reply of
NO_REPLYto asessions_sendrequest that needs a result. OpenClaw then runs a short tool-free step to get the answer. That step crashed withRangeError: Invalid time valuebefore it made any model call when the session used a context engine that adds messages without a timestamp. Lossless Claw adds summary, focus-brief and recall messages that way. The requester got no answer and the turn was logged as incomplete (incident runbd2d3478-18a1-4ee0-b7db-43c2d83dd497, 2026-11-19).User Impact
User impact: sessions that use a timestamp-less context engine such as Lossless Claw get a real final answer again after a tool-only turn, instead of an "incomplete turn" error. Ordinary turns send the same model requests as before.
Why This Change Was Made
The tool-free step first trims the turn's messages to fit the model-context limit. To do that it builds temporary bookkeeping entries, and it gave each one a timestamp converted from its message's timestamp. A message without a timestamp made that conversion throw. Every entry now gets the same fixed timestamp. Nothing reads these timestamps: the trimming logic does not look at them, and the entries are never saved or sent to the model. Sizing and model input come from the messages themselves, so request bytes are unchanged.
Rejected alternative: filling in missing timestamps where the context engine's output enters OpenClaw. OpenClaw adds a time stamp to user-message text from the message timestamp, so this would change summary text the model sees. A current time would break the prompt cache, and a fixed time would show the model a 1970 date. A separate Lossless Claw change will add timestamps on the plugin side. This PR is the guard on the OpenClaw side.
Accepted risk: if a later change makes the trimming logic read entry timestamps, this path would give it the 1970 value. The new test checks the trimmed result, not just that nothing throws, so such a change would fail it. No other
new Date(x).toISOString()call insrc/agents/embedded-agent-runnerorsrc/agents/harnessconverts a timestamp taken from a message. The others use the current clock or validated dates.Evidence
Regression test (
attempt-history-prepare.test.ts, two cases). The tool-free step gets a summary-style user message with no timestamp, one with aNaNtimestamp, and an exec tool call and result. With the default limit, all four messages reach the agent unchanged. With a tight limit, the large tool result is replaced by the usual omission notice while the timestamp-less messages stay. Both cases fail onorigin/mainwithRangeError: Invalid time valueand pass with the fix. Neighboring suites pass:settled-turn-finalization,finalization-scopeandattempt-prompt-phase(79 tests).pnpm check:changedpasses, including typecheck, lint and format.Real behavior on the Mac Studio. Each commit ran in a Crabbox
local-containerlease launched on the Studio (node:24.22.1-trixie, imagesha256:f1e03497…, 8 CPU / 24 GB) from a clone at the pushed commit. Each run used:{ role: "user", content }summary message with no timestamp to every assembled contextI used a small test engine instead of Lossless Claw 40833c3 because it isolates the one trigger, missing timestamps, and needs no Lossless Claw database setup. The scenario matches the incident. A requester session asks the model to call
sessions_sendinto a WebChat session. There the model runs oneexec, then repliesNO_REPLY, which the request does not allow.f250a678(leasecbx_0c02ea0561f9)5f3bb45b(leasecbx_b865184e14f8)payloads=0 tools=1)NO_REPLY_RECEIVED errorREPLY: The exec tool ran 'echo settled-proof-01aca19e' once, and it returned 'settled-proof-01aca19e'. …Base log, which matches the incident. Inside the container the
RangeErrortext readsInvalid Datebecause the test runtime uses the OpenClaw Bun fork. Node saysInvalid time value.Ordinary turns are unchanged. I compared the three model requests whose inputs are the same in both runs: the ordinary turn, the requester's first request, and the target's first incident request. After masking per-run values (container hostname, lease workdir path, UUIDs, timestamps), the request bodies are byte-identical between base and fix, including the system prompt and tools. The raw size difference is 2 bytes in each case, all from the container hostname length.
CI note: the first
checks-ui-e2e (1/2)attempt on5f3bb45b(job 135492776612) failed before any test ran. Installing WebKit system packages timed out on the apt mirrors (WebKit system packages did not download from the fallback archive mirrors (exit 124)), andopenclaw/ci-gatefailed only because of that job. This was an infrastructure flake, not a failure inherited from main: recentmainruns of the same workflow are green, and this PR touches only the embedded-runner file and its test. One rerun passed (job 135515231051), andci-gatefor that run now passes.Commands
On the Studio, from a clone under
~/crabbox-src/sftchecked out at each commit:Both runs exited 0 and both leases reported
"leaseStopped":true. The proof harness is not committed. The API key was passed only through the environment.🦞 Made with OpenClaw