Skip to content

Fix revert handling for tool calls in the same step as the reverted edit - #522

Merged
AshishKumar4 merged 1 commit into
mainfrom
revert-elision-same-step
Sep 23, 2026
Merged

AshishKumar4 merged 1 commit into
mainfrom
revert-elision-same-step

Conversation

@AshishKumar4

@AshishKumar4 AshishKumar4 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

When the user rewinds an agent step, replay replaces that step's readFile results with a note. The check only looked at the message holding the tool calls. A step writes more than that though: the tool-call message, then any action, useGadget or connectionRequest records from the step, then a "changes" message with the edits. The rewind starts at the "changes" message, so a read in the same step as an edit was never marked, and replay showed the reverted content as current.

Concretely: the agent writes secret = 42 and reads the file back in the same step. The user rewinds. Next turn, the model still sees secret = 42.

The check now finds the step's "changes" message, past any of those records, and consults its status. It stops at the next assistant message or at a user's own changes, since a step that made no edits has no changes message and a later one must not be taken for it.

The writeFile/editFile un-marking from #513 is removed, per the review: the revert message already says what was undone.

Found while adding grep in #494, which records its output the same way.

The test writes, reads, and requests a connection in one step, so the request record sits between the tool-call message and the changes message. It rewinds the step and checks the replayed read is elided. It fails on main, and it fails with a check that only looks at the adjacent message. To write it I had to let the scripted model return more than one tool call per step and add revertChanges to the test session driver.

@github-actions github-actions Bot added the kernel Changes to the Workshop kernel label Sep 17, 2026
Comment thread packages/workshop-backend/src/agent.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 17, 2026

Copy link
Copy Markdown

Posted 1 actionable inline review finding.

github run

@github-actions

Copy link
Copy Markdown

Preview: pr522-revert-elisio-ee0018c8

https://pr522-revert-elisio-ee0018c8-router.cloudflare-os-previews.workers.dev

Dashboard · deleted when this PR closes

devin-ai-integration[bot]

This comment was marked as resolved.

@AshishKumar4 AshishKumar4 changed the title Elide a readFile that saw an edit the user then reverted Fix revert elision for a readFile in the same step as an edit Sep 17, 2026
@ask-bonk

ask-bonk Bot commented Sep 17, 2026

Copy link
Copy Markdown

Performance is inconclusive because every cohort is marked non-comparable due to changed eval definitions. Across three trials each, pass counts stayed 0/3, 0/3, and 3/3, while mean durations fell 8.9%, 6.5%, and 36.9%, respectively. Project-doc most concretely skipped a README read more often, with mean tool calls dropping 4.67 to 4.33 and cost dropping $0.0111 to $0.00845. With only three stochastic trials, these differences could be sampling variation.

github run

@AshishKumar4

Copy link
Copy Markdown
Contributor Author

Ignore the last bonk comment

@AshishKumar4
AshishKumar4 added this pull request to stack #527 September 18, 2026 02:53
@AshishKumar4
AshishKumar4 force-pushed the revert-elision-same-step branch from 30a5be3 to f4991e7 Compare September 18, 2026 13:59
@ask-bonk

ask-bonk Bot commented Sep 18, 2026

Copy link
Copy Markdown

No additional actionable findings beyond the existing inline review comments.

github run

@ask-bonk

ask-bonk Bot commented Sep 18, 2026

Copy link
Copy Markdown

Performance is inconclusive because all cohorts are non-comparable after eval-definition changes. Appointment stayed 10/10, expense-ledger fell 7/10 to 5/10, and project-doc rose 8/10 to 9/10. Most notably, expense-ledger used 38.5% fewer tool calls yet took 30.7% longer. With 10 stochastic trials per cohort, sampling variation may explain these mixed results.

github run

@AshishKumar4
AshishKumar4 force-pushed the revert-elision-same-step branch from f4991e7 to 7f8922c Compare September 18, 2026 20:54
@github-actions github-actions Bot added workshop/frontend Changes to the Workshop frontend workshop/shared Changes to shared Workshop APIs labels Sep 18, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@AshishKumar4
AshishKumar4 force-pushed the revert-elision-same-step branch from 7f8922c to 82e3640 Compare September 18, 2026 20:59
@AshishKumar4 AshishKumar4 changed the title Fix revert elision for a readFile in the same step as an edit Fix revert handling for tool calls in the same step as the reverted edit Sep 18, 2026
@github-actions github-actions Bot removed workshop/frontend Changes to the Workshop frontend workshop/shared Changes to shared Workshop APIs labels Sep 18, 2026
ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk

ask-bonk Bot commented Sep 18, 2026

Copy link
Copy Markdown

Submitted 1 actionable inline review comment.

github run

@kentonv kentonv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually buggy, but I also think maybe we can just remove this entirely?

Comment thread packages/workshop-backend/src/agent.ts Outdated
Comment thread packages/workshop-backend/src/agent.ts
Comment thread packages/workshop-backend/src/agent.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 18, 2026

Copy link
Copy Markdown

Performance is inconclusive because all cohorts are non-comparable after eval-definition changes. Across 10 trials each, appointment fell from 10/10 to 9/10, while expense-ledger and project-doc each improved by one pass; mean durations fell 6.8%, 39.9%, and 8.8%, respectively. Expense-ledger showed the clearest tool-use shift, dropping from 26.8 to 23.4 calls and 1.2 to 0.7 errors, with cost down 36.8%. These modest pass-rate changes and efficiency gains could reflect stochastic variation.

github run

@AshishKumar4
AshishKumar4 force-pushed the revert-elision-same-step branch from 82e3640 to c7aa651 Compare September 21, 2026 16:01

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread packages/workshop-backend/src/agent.ts
@ask-bonk

ask-bonk Bot commented Sep 21, 2026

Copy link
Copy Markdown
  • [P2] packages/workshop-backend/src/agent.ts:1672: Compaction can summarize the assistant read while retaining its later changes record. After an intervening connection request is resolved, it becomes a valid compaction boundary. Reverting from changes preserves that earlier checkpoint, leaving reverted file content in the summary. Prevent compaction from splitting an assistant step from its barrier, or invalidate such checkpoints on revert.

github run

@ask-bonk

ask-bonk Bot commented Sep 21, 2026

Copy link
Copy Markdown

Performance is inconclusive because every cohort is non-comparable after eval-definition changes. Appointment stayed 10/10, expense-ledger rose 7/10 to 8/10, and project-doc rose 7/10 to 9/10. Project-doc improved without changing mean tool use at 4 turns, 5 calls, and 0 errors, while mean durations fell 12.2%, 1.8%, and 1.1%, respectively. With 10 stochastic trials per cohort, these differences could reflect sampling variation.

github run

@AshishKumar4
AshishKumar4 force-pushed the revert-elision-same-step branch from c7aa651 to 7eaffa7 Compare September 22, 2026 14:33
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown

LGTM!

github run

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown

Performance is inconclusive because all cohorts are non-comparable after eval-definition changes. Across 10 trials, appointment stayed 10/10, expense-ledger stayed 6/10, and project-doc rose from 7/10 to 9/10. Mean duration rose 33.0% for appointment but fell 9.6% for expense-ledger and 7.4% for project-doc. Expense-ledger showed the clearest tool-use improvement, with turns, calls, and errors falling from 16.8/19.7/1.5 to 11.6/15.4/0.1, though stochastic variation could explain the result.

github run

When the user rewinds an agent step, replay replaces that step's readFile
results with a note, so the model doesn't keep believing content that no
longer exists. The check looked only at the message holding the tool
calls. But a step's edits land in a "changes" message written after that
one, with any action, useGadget or connectionRequest records of the step
in between, and the rewind starts at the changes message. So a read in
the same step as an edit was never marked and replayed with the reverted
content.

The check now also finds the step's changes message, past those records,
and consults its status. It stops at the next assistant message or at a
user's own changes, since a step that made no edits has no changes
message and a later one must not be taken for it.

The writeFile and editFile un-marking added in #513 is removed: the
revert message already tells the model what was undone, and un-marking
was not intended.

The test writes a file, reads it back, and requests a connection in one
step (the request record sits between the tool-call message and the
changes message), rewinds the step, and asserts the replayed read is
elided. It fails without the fix, and it fails with a check that looks
only at the adjacent message. The scripted model can now answer one
request with several tool calls, and the session driver gains
revertChanges, both for the test.
@AshishKumar4
AshishKumar4 force-pushed the revert-elision-same-step branch from 7eaffa7 to f72f35b Compare September 23, 2026 16:48
@ask-bonk

ask-bonk Bot commented Sep 23, 2026

Copy link
Copy Markdown

LGTM!

github run

@AshishKumar4
AshishKumar4 removed this pull request from stack #527 September 23, 2026 16:52
@AshishKumar4
AshishKumar4 merged commit 6f7617a into main Sep 23, 2026
17 of 18 checks passed
@AshishKumar4
AshishKumar4 deleted the revert-elision-same-step branch September 23, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Changes to the Workshop kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants