Skip to content

ui: resume agentic loop after page reload - #97

Draft
allozaur wants to merge 3 commits into
allozaur/feat/hf-oauth-sign-infrom
allozaur/fix/agentic-loop-resume-after-reload
Draft

allozaur wants to merge 3 commits into
allozaur/feat/hf-oauth-sign-infrom
allozaur/fix/agentic-loop-resume-after-reload

Conversation

@allozaur

@allozaur allozaur commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Overview

Reloading a chat in the middle of a multi-step tool run now picks the run back up and finishes it, instead of leaving the chat stuck or half-finished.

Additional information

Stacked on #92, so merge that first. Known gaps: the resume marker lives in per-tab sessionStorage, so closing the tab ends the run. A streaming tool's partial output is kept and the tool is not re-run.

Cause

The agentic loop runs in the browser tab. When the page reloads, reattaching to the server stream only replays the current LLM turn, so tool execution and the following turns never continue.

What changed
  • Mark an in-flight agentic flow in sessionStorage and clear the marker when the flow ends.
  • After discovery settles, rebuild the interrupted turn from persisted messages: resume from unanswered tool calls, or start the next LLM turn when all results are saved. Already-answered tool calls are skipped.
  • Clear streaming state per message id on stream cleanup, so a late attach cannot wipe a newer generation's permission card.
  • Export parseToolCalls and copy $state values with $state.snapshot before writing them to IndexedDB.
  • Rebased onto the PR 92 branch, which sits on the new ui/apps/chat layout.
Testing
  • svelte-check: 0 errors. ESLint, Prettier and unit tests (810) pass on the stacked branch.
  • Manual in the running app with the Sage model: a run with no reload completes; a reload after the first tool result resumes and finishes; a reload during the first LLM turn reattaches and completes. Manual runs were made before the stacking.
  • Not covered yet: a reload between turns with the final fix, a reload during a streaming tool, a reload with the page open in another tab, and the Qwen model.

Requirements

@allozaur
allozaur force-pushed the allozaur/fix/agentic-loop-resume-after-reload branch from 648985b to 682c8fd Compare November 20, 2026 16:09
The share dialog gets a "Sign in with Hugging Face" button next to the
access-token form. It runs OAuth with PKCE in the browser: the app
registers itself with Hugging Face for the redirect URL of the origin it
is served from, opens the authorization page in a popup (or this tab when
the popup is blocked), and the page that comes back trades the code for
tokens and tells the other tabs on a BroadcastChannel. Tokens stay in
localStorage and are renewed with the refresh token before they expire.

When Hugging Face turns the registration down or grants no write access,
the dialog says so and points to signing in with an access token.

Assisted-by: Claude (Opus 5.5 Medium)
Signing in with Hugging Face asked for write-repos and manage-repos, so the
consent page said the app could manage every repository of the account. It
now asks for contribute-repos: the app can create datasets and write only to
the ones it created.

A client registered for other scopes registers again on the next sign-in. A
share to a dataset the sign-in may not write to now says why and what to do,
in place of the Hub's bare 403.

Assisted-by: Claude (Opus 5.5 Medium)
The agentic loop runs in the browser tab, so a reload on /chat/[id]
dropped tool execution and the following LLM turns. Reattaching to the
server stream only replays the current LLM turn.

Mark an in-flight agentic flow in sessionStorage and, once discovery
settles, rebuild the interrupted turn from persisted messages. Resume
from the unanswered tool calls, or start the next LLM turn when all
results are in. Already-answered tool calls are skipped.

Also clear streaming state per message id on stream cleanup so a late
attach cannot wipe a newer generation's permission card.

Assisted-by: Claude (Opus 5.5 Medium)
@allozaur
allozaur force-pushed the allozaur/fix/agentic-loop-resume-after-reload branch from 682c8fd to e0407b8 Compare November 23, 2026 11:46
@allozaur
allozaur changed the base branch from master to allozaur/feat/hf-oauth-sign-in November 23, 2026 11:46
@allozaur
allozaur force-pushed the allozaur/feat/hf-oauth-sign-in branch 4 times, most recently from 9f91b89 to d94b69b Compare November 24, 2026 18:57

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant