Repository navigation
fix: rebuild from history past reads the provider answered itself - #174
Conversation
A Run Cursor cuts right after a tool result can only recover through a history rebuild, and that rebuild required a host result for every exec except AwaitShell's terminal-record polls. Any other read the provider answers itself refused it with missing-host-results. Live, that was mostly the empty read before a new file's edit. Record which kind of answer the provider gave for each exec (recordProviderAnswer) and decide coverage at history-check time (historyCoverage): - terminal-record and missing-target reads need no result; - a new file's empty edit read and a Task attachment read need their call's host result in the rebuilt prompt; - refusals and every other exec still need their own result, and any answer in the cut attempt stays a barrier. Fixes #172.
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThe PR lets post-result recovery rebuild past more reads the provider answered itself.
No actionable issues found. Review used source and test inspection; no tests or live host runs were executed.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Ran it on 90ff0d5 with the test-only cut on top, plain
So it matches what you expected in both cases. |
|
@nkoynov, thank you! That's the confirmation we needed. What you raised in #140, and what fixes it:
|
…answers-172 # Conflicts: # CHANGELOG.md
Fixes #172.
Problem
When Cursor cuts a Run right after a tool result is written, the only safe recovery is a rebuild from host history. #164 let that rebuild skip AwaitShell's terminal-record polls, but it still needed a host result for every other exec. So any other read the provider answers itself refused the rebuild with
missing-host-results.@nkoynov, in your host logs for Nov 2–9, 25 of 82 Runs rebuilt after a post-result cut had such reads. In 22 of them the only one was the empty read before a new file's edit. The edit's write always went to the host, and its result was in the Run.
Fix
recordProviderAnswer(src/replay-safety.ts) records which kind of answer the provider gave for each exec. It replacesrecordTerminalRead.historyCoveragedecides at history-check time whether host history holds everything the Run did:file_not_found/invalid_file) need no result;list_mcp_resourcesand every other exec still need their own result.recovery: history-checkline also printsmissingReads=,editHandshakes=andattachmentReads=.Nothing new is sent on normal turns, and a rebuild seeds host history as before, so prompt caching is unaffected. Both majors share this path.
Verification
test/run-error-host.test.ts, post-result drop matrix:missing-readandnew-file-editnow rebuild. Onmainboth fail withmissing-host-results execs=3 results=2.missing-read-after-result(answer in the cut attempt) andrefused-read(no advertisedread, so the provider refuses the call) are still refused.test/replay-safety.test.ts: unit tests forhistoryCoverage:recordProviderAnswermarks only the current Run's exec.bun run typecheck,bun run buildandbun test ./testpass (3387 pass, 5 skip, 0 fail).@nkoynov, thanks for offering the live check. The new-file cut on OpenCode 2.x against this branch should show
reason=completed-tool-results ... editHandshakes=1andkind=rebase, with the file written once.