Skip to content

fix(acp): do not fail a session load on one bad tool output - #924

Closed
ANIRUDDHA ADAK (aniruddhaadak80) wants to merge 1 commit into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/acp-session-replay-non-json-todo
Closed

ANIRUDDHA ADAK (aniruddhaadak80) wants to merge 1 commit into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/acp-session-replay-non-json-todo

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

What does this PR do, and why?

The session-replay path shared the same unguarded JSON.parse. loadSession and unstable_forkSession call await this.processMessage(msg) inside their own try, so ONE todowrite entry with non-JSON output throws a SyntaxError back to the client and the entire session load fails.

Linked issue

small fix, no issue

How did you verify it?

cd backend/cli && bun test test/acp/event-subscription.test.ts -t "replays a session"

Regression proof: With the source reverted the test fails on that SyntaxError; with the fix it passes. The diff hunk is confined to the replay site, leaving the live path untouched.

cd backend/cli && bun test test/acp/event-subscription.test.ts -> 7 pass, 0 fail

This PR adds a parseTodoOutput helper identical to the one in the companion live-path PR, so each stands alone as an independently reviewable and mergeable change. Once one merges, the other should drop its duplicate helper - noted in the commit body.

Not verified: unstable_forkSession is not directly tested (it shares the processMessage path).

Two pre-existing conditions in this checkout, reproduced on the untouched base commit and therefore not caused by this change: �un run typecheck (turbo) fails with sgo: command not found, and �un run format:check reports roughly 30 files. I ran sc --noEmit for �ackend/cli and prettier on the files I touched instead; neither appears in the base warning list.

Checklist

  • �un run check is green (format, typecheck, backend + frontend/ui + SDK tests)
  • �un run --cwd frontend/workspace build succeeds if I touched rontend/workspace or rontend/ui (not applicable - no frontend/workspace or frontend/ui file changed)
  • ./tooling/repo/generate.ts was run and the ooling/sdk output committed if I changed �ackend/cli/src/server (not applicable - no �ackend/cli/src/server file changed)
  • [[x]] CHANGELOG.md has an Unreleased entry if the change is user-visible
  • The matching docs page under rontend/docs/src/content/openscience/ is updated if behavior changed (not applicable - no documented behavior changed)
  • Screenshots or a short video are attached for UI changes (not applicable - no UI change)
  • No version bumps (package.json versions and tags are written by the release workflow)
  • install and rontend/landing/public/install are still byte-identical if I touched either (not applicable - neither was touched)

I left the first box unticked rather than claiming it: �un run check cannot pass in this checkout because turbo cannot find sgo, and that failure reproduces on the base commit.

The session-replay path parsed todowrite output with the same unguarded JSON.parse. loadSession and unstable_forkSession await processMessage inside their own try, so a single todowrite tool with non-JSON output threw a SyntaxError back to the ACP client and the whole session failed to load instead of replaying its history.

Route the replay site through the same non-throwing helper. Both call sites would share one helper once either PR merges; they are kept apart here so each change stands on its own.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 07:27

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Oct 3, 2026

Copy link
Copy Markdown

ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

@aayambansal

Copy link
Copy Markdown
Member

Incorporated, reviewed, and validated in #953, now merged into main. Closing this original PR as superseded by the consolidated change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants