Repository navigation
fix: let long chats fork without losing searchable history - #205671
Conversation
Budget inherited context at the built-in API runner’s request boundary rather than rejecting the whole branch. Keep native and automatic fork admission unchanged. Co-authored-by: hannesrudolph <[email protected]>
Co-authored-by: hannesrudolph <[email protected]>
Worked on by: - @hannesrudolph Co-authored-by: hannesrudolph <[email protected]> OpenClaw-Publication: 9532ef09-a309-4d7f-91df-985ad84b6a4b
|
🦞👀 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. |
Co-authored-by: hannesrudolph <[email protected]>
Co-authored-by: hannesrudolph <[email protected]>
Worked on by: - @hannesrudolph Co-authored-by: hannesrudolph <[email protected]> OpenClaw-Publication: 460097f2-eb9b-449b-a5b1-e48550923c80
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves searchable history when explicitly forking an API chat and fits inherited context at the model-request boundary. Example: Fork a saved conversation whose estimated history exceeds a 32,768-token model window.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a current long-chat branching failure, and no blocking defect was identified in the introduced changes. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway session creation copies the selected transcript into an independent child; the embedded runner prepares that child's model context while transcript search continues to read its saved history. flowchart LR
A[Explicit fork request] --> B[Gateway creation owner]
B --> C[Independent child transcript]
C --> D[Transcript search]
C --> E[Embedded request preparation]
E --> F[Budget inherited turns]
F --> G[Model request]
Technical reviewBest possible solution: Preserve the complete copied transcript and fit only inherited model context through the existing request-budget and selection owners. Do we have a high-confidence way to reproduce the issue? Current-main source still rejects oversized selected history before copying it, consistent with the linked incident and supplied base reproduction; this review executed no target code. Is this the best way to solve the issue? Separating transcript copying from request fitting addresses the blocked API-chat workflow without raising model limits or rewriting the parent, while reusing existing budget and tool-pairing selection logic. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b9d0210f31ba. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +248, Tests +349, Docs 0. Total +597 across 23 files. Added test files: 3. 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 25, 2026, 8:50 PM ET / November 26, 2026, 01:50 UTC. |
…205671) Co-authored-by: hannesrudolph <[email protected]>
Fixes #174730 (incident evidence)
What Problem This Solves
Forking a long chat could fail before creating the child because the Gateway compared the selected history with the child model's input capacity. That prevented branching even though the full transcript need not be sent to the model. The incident showed the rejection; the later roster reading did not establish which estimator input produced it.
User Impact
User impact: an explicit chat fork on the built-in OpenClaw API runner keeps the selected, searchable history and can continue from the recent decision. The child writes to its own transcript. This does not raise a model cap, shorten the parent, or change automatic/subagent or native-runtime fork admission. Active parents still require a completed fork point; reset boundaries and access checks stay in place.
Why This Change Was Made
Copying a branch and fitting a model request are different operations. The runner now selects inherited turns against the space left after instructions, tools, current input and output reserve. Child-owned turns stay under normal compaction. Reply preflight no longer mistakes unmeasured copied history for a child request. Simply removing the creation check was insufficient: in the control run the first request summarized the old ledger and missed the recent decision.
Evidence
f57a179eb81fc48c3d3f64bf2489c1fec3537bf1, the realsessions.createWebSocket call returnedINVALID_REQUEST (45912/32768 tokens). No child and no model call. The old ledger alone was 104,868 tokens undero200k_base, not an inflated usage counter.d3aad208067b5e4eb158666a554d4a6e0e15bac8, same saved synthetic parent. Child-scopedsessions.searchfound the old receipt in the child's own transcript. The neutral question did not repeat the answer. The first and only outbound request contained the recent decision, instructions and four tools, but none of the 2,800 old ledger rows. The built-in runner sent it to a real local Qwen2.5-0.5B-Instruct model via llama.cpp: 6,987 measured input + 2,048 reserved output = 9,035 / 32,768 tokens. The generated and delivered answer was “The QA canary code we chose is CobaltTrellis49.” All seven parent events and the active leaf were unchanged. This is not a Gemini or live-parent retest.Reported, investigated and scoped by @hannesrudolph.
Work sessions
Linked for team reference; these sessions aren’t public.
Worked on by