Skip to content

fix(app): agents see working sessions, archive confirmations name the requester, and session.stop by id - #4893

Closed
yomgui wants to merge 4 commits into
devfrom
fix/agent-archive-working-sessions
Closed

yomgui wants to merge 4 commits into
devfrom
fix/agent-archive-working-sessions

Conversation

@yomgui

@yomgui yomgui commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Problem and RCA

On 2026-09-11 11:27 a session finished its work and, still inside its own assistant turn, called session.archive on itself. The app correctly saw the target as working (it was: the requester was mid-tool-call) and opened the "This session is still working" confirmation. Three things went wrong around that correct decision:

  1. The requester was discarded. The OpenCode plugin attaches origin: { sessionId } to every bridged command (apps/server/src/opencode-plugins/openwork-extensions-preview.ts affordanceOrigin) and the control provider hands it to actions as helpers.origin, but session.archive's execute: async (args) => … ignored it (session-control-actions.ts). The modal could not say who asked, and could not tell that requester == target.
  2. Agents had no status. session.list_sessions returned {sessionId,title,workspace,updatedAt,pinned} and session.read only the transcript; the activity store's idle/thinking/responding/waiting state was never exposed, so an agent could not check before archiving.
  3. The 5 s error was the bridge, not the archive. apps/server/src/ui-control.ts resolves "The OpenWork window did not answer within 5 seconds" when the window has not replied; the window replies only when the action settles, and the archive promise settles only when the dialog closes. A human-gated dialog can never answer in 5 s, so the agent saw a generic transport error while the dialog stayed open.

Related: #4832 (modal names the target), #4818 (toast names the target), #4825, #4840, draft #4843.

What changes

Principle (product decision, 2026-09-11): the warning goes back through the channel the request came from. The person gets a dialog; an agent gets a structured result in its own conversation, never a dialog.

  • B · status. session.list_sessions entries carry status (activity store: idle/thinking/responding/waiting/compacting/error) and working. session.read carries status (engine: idle/busy/retry/waiting) and working; an unreadable probe reports working: true, never a false "safe". Affordance descriptions tell agents to check working first.
  • Agent path of session.archive. On a working target the bridge returns { ok:false, code:"target_working", sessionId, title, hint } — "if the user wants it closed, call session.stop first, then archive; if not, leave it running". A session archiving itself or its parent mid-turn gets code:"self_archive_while_working" — "finish the turn; the reviewer archives". No dialog, no 5 s stall, no deferral/queue. Idle targets archive as before. Action-supplied code/hint propagate through the bridge (packages/types failure enum + optional hint); actions learn the channel via helpers.bridged.
  • Human path of session.archive. The confirmation (fix(app): leave archived sessions and explicitly stop active work #4640/fix(app): identify working sessions before stop and archive #4832) is kept but simplified to the essentials: "This session is still working: <title>" / "Stop the current task and archive?" / Keep session open · Stop and archive. Workspace/id rows and the consequences paragraph are removed; no requester row (the person just clicked it).
  • C · session.stop { sessionId }. The Stop button for any loaded session by id (user decision: "an agent should be able to stop a session if a user asks him to do so"). Same trust level as session.create/session.archive, no confirmation: aborts the turn, cancels subtasks and queued messages, no navigation. Idle → {ok:true, alreadyIdle:true}; success → {ok:true, stopped:true, sessionId, title}; unknown id → structured error. Safeguard is attribution: "Session stopped: <title> — Requested by " as a toast and as a notification-center entry with a View action (new open-session notification action) plus the control-action narration. Reuses the archive path's interruption machinery; v2 preview disabled with its own reason. Not chained into archive.
  • The mailbox's 5 s fallback message names the confirmation case (still reachable by window.confirm-gated actions such as session.delete).

Warden NLX-3N2 ("session.stop can interrupt any loaded session without confirmation") describes this decision; it is intentional (attribution, not a gate) and left for a human approver.

Product/design notes

Patterns from comparable products (official docs, 2026-09-11; not a claim of design approval): a state machine visible to the caller before lifecycle verbs (Cursor Cloud Agents run.status, Devin status_detail); stop/cancel as a first-class verb separate from archive (Cursor …/cancel, Devin terminate ?archive=true); structured conflicts instead of transport errors (409 agent_busy, run_not_cancellable); initiator attribution on lifecycle events (Slack "X archived this channel", GitHub Actions triggering actor). Docs: packages/docs/start-here/do-work-with-it/cross-chat-memory.mdx gains "How agents manage other sessions".

Verification

Head: 7bd7f33e0b1a0c765500f300ab44a085c85bcddb (four commits, all signed and signed off).

Command Lane Result
bun test --isolate tests/session-archive-agent-contract.test.tsx tests/notification-store.test.ts (apps/app) Local Exit 0: 18 passed (11 contract + 7 store)
bun --conditions=development test src/opencode-plugins/openwork-extensions-preview.test.ts src/opencode-plugins/openwork-provider-adapters.test.ts (apps/server) Local Exit 0: 36 passed
pnpm evals:pr specs/session-list-sessions-inventory.test.ts Local Exit 0: 4 passed
tsc --noEmit in apps/app, apps/server, packages/types Local Exit 0
git diff --check origin/dev...HEAD Local Exit 0
pnpm evals:e2e session-archive-agent-requester (OPENWORK_EVAL_DAYTONA=1 OPENWORK_EVAL_REF=7bd7f33e0…, Infisical injection) Fresh Daytona Exit 0: 1 passed, 0 failed, 0 skipped; refMismatch: false
pnpm evals:e2e session-archive-confirmation-identity (same env) Fresh Daytona Exit 0: 1 passed, 0 failed, 0 skipped — simplified human confirmation, unchanged stop/Undo behaviour

Verdict: Passed. Commit-bound evidence for both Daytona runs on 7bd7f33e0 is published in the sticky comment below.

The e2e spec drives the real bridge (POST /experimental/ui-control/request with origin): two real held tasks; list_sessions reports working; archiving working B from A2 returns target_working in < 5 s with no dialog and nothing stopped; A1 archiving itself returns self_archive_while_working with no dialog; the person's own sidebar click shows the simplified confirmation (title, one question, no metadata rows) and Keep leaves B running; idle bridged archive completes; session.stop on working B ends its run (aborts only B), notification toast + persisted center entry name target and requester, idempotent second stop, unknown id error. session-archive-confirmation-identity is updated to the simplified dialog and still covers duplicate/blank/long titles, no mutation before consent, and B-only stop with Undo.

@mintlify

mintlify Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
differentai 🟢 Ready View Preview Sep 11, 2026, 5:40 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@vercel

vercel Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Ignored Ignored Preview Sep 11, 2026 5:39pm UTC
openwork-den Ignored Ignored Preview Sep 11, 2026 5:39pm UTC
openwork-diagnostics Ignored Ignored Preview Sep 11, 2026 5:39pm UTC
openwork-landing Ignored Ignored Preview Sep 11, 2026 5:39pm UTC

…hive one

An agent archived its own running session from inside its turn: the app
asked the person to confirm Stop and archive, but the bridge mailbox gave
up after 5 s with a generic "window did not answer" error, and the dialog
could not say who had asked.

- session.list_sessions entries and session.read results carry `status`
  and `working` so agents can check before touching a session.
- The Stop-and-archive dialog names the requesting agent session (title and
  id), or "this session itself" when a session asked to archive itself.
- Bridged commands that open a human-only dialog answer at once with the
  structured code awaiting_user_confirmation and a hint naming target and
  requester; the dialog stays open for the person. Action-supplied codes
  and hints now reach the bridge unchanged.
- The mailbox fallback message names the confirmation case.

Signed-off-by: Guillaume Loret <[email protected]>
…gent

An agent that can start sessions could not stop one. session.stop
{ sessionId } is the Stop button for any loaded session: it aborts the
turn, cancels subtasks and queued messages, and never navigates. Idle
targets return alreadyIdle; unknown ids are a structured error. The
safeguard is attribution: the stop shows "Session stopped: <title>" with
the requesting agent session as a toast and as a notification-center entry
with a View action. Archive semantics are unchanged.

Signed-off-by: Guillaume Loret <[email protected]>
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Warden review summary — Blocked

Native findings: 2. Blocking policy matches before consolidation: 1. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (179169 ms), confidentiality-review (244822 ms), spec-provenance-review (337014 ms), desktop-den-sync-review (351799 ms).

Blockers

  • 2AY-HF9 · high · diff-security-review · apps/app/src/react-app/domains/session/control/session-control-actions.ts:309

Advisories

  • TW3-UT2 · medium · spec-provenance-review · evals/specs/session-archive-agent-requester.e2e.test.ts:36

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 3
  • Distinct heads in retained window: 3
  • Current unresolved Warden threads: 0 of 3 observed
  • Observed resolved/unresolved transitions in retained snapshots: 3 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 3
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 3/20 run attempts retained; truncated: false
  • Transition snapshot: 3/3 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

An agent's request must never open a dialog for the person. session.archive
on a working session through the agent bridge now returns a structured
refusal in the agent's own conversation: target_working (stop it first with
session.stop if the user wants it closed, otherwise leave it running) or
self_archive_while_working (finish the turn; the reviewer archives). Idle
targets archive as before. The awaiting_user_confirmation race is gone.

The person's own archive of a working session keeps its confirmation but
simplified to the essentials: the session title, one question, Keep session
open / Stop and archive. The Requested by row and forensic detail are
withdrawn from the dialog; attribution stays on session.stop.

Signed-off-by: Guillaume Loret <[email protected]>
@yomgui

yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Test evidence — agents see which sessions are working, an agent's archive of a working session is refused through its own channel while the person keeps a simple confirmation, and session.stop is attributed — ✅ passed

SHA 7bd7f33 · sandbox ref 7bd7f33 · engine v1

✅ 0/2 screenshots passed · 0 expectations passed · 0 failed · 0 pending

[world] desktop(daytona) · mock(mcp) · workspace(/tmp/openwork-session-archive-1789148460348-72114-a) · [seed:raw] evalIn() ×23
[agent] run(session.open)
[probe] eventually(owning composer is ready)
[user] type(composer, "Keep Archive other workspace running for requester proof.", replace) · press(Enter)
[probe] eventually(task reaches held provider)
[agent] run(session.open)
[probe] eventually(owning composer is ready)
[user] type(composer, "Keep Chat A running for requester proof.", replace) · press(Enter)
[probe] eventually(task reaches held provider) · hash
[agent] run(session.list_sessions)
[probe] eventually(both running sessions report working)
[agent] listActions · desktopApi(POST /experimental/ui-control/request)
[user] notSee(text=This session is still working)
[probe] hash
[agent] desktopApi(POST /experimental/ui-control/request)
[user] notSee(text=This session is still working) · hover(testId=sidebar-session-ses_f6e70fde8ffeXDiSRr1THkndrs) · testId=session-archive-ses_f6e70fde8ffeXDiSRr1THkndrs · click(testId=session-archive-ses_f6e70fde8ffeXDiSRr1THkndrs) · see(text=This session is still working) · screenshot · label=Keep session open · click(label=Keep session open) · notSee(text=This session is still working)
[probe] hash
[agent] desktopApi(POST /experimental/ui-control/request)
[user] notSee(text=This session is still working)
[probe] eventually(idle neighbor is archived)
[agent] desktopApi(POST /experimental/ui-control/request)
[user] notSee(text=This session is still working)
[probe] eventually(B's run ends) · hash
[user] see(text=Session stopped: Archive other workspace) · see(text=Requested by The agent in "Chat A" ses_f6e70fe35ffe1cISxcgWxztI4J) · screenshot
[probe] storage(openwork:notifications:v1)
[agent] desktopApi(POST /experimental/ui-control/request) ×2
[user] notSee(text=This session is still working)
steps 1 ✅ two independent real tasks run while A remains visible (4.7s) · 2 ✅ session.list_sessions tells agents which sessions are working before they touch them (0.5s) · 3 ✅ an agent archiving another working session is refused with target_working: no dialog, no stop, no 5 s stall (3.4s) · 4 ✅ a session archiving itself mid-turn is refused with self_archive_while_working, no dialog (3.3s) · 5 ✅ the person's own click keeps a simple confirmation: title, one question, Keep or Stop and archive (8.6s) · 6 ✅ an agent stops a working other-session by id: its run ends, nothing navigates, and the notification names target and requester (8.0s)
verdict passed · 11 user observations (notSee ×6, see ×3, screenshot ×2) · 12 probes · steps 6/6

⚪ UNVALIDATED — 1. agents see which sessions are working, an agent's archive of a working session is refused through its own channel while the person keeps a simple confirmation, and session.stop is attributed artifact 1

  • ⚪ UNVALIDATED — no visual expectations recorded.

agents see which sessions are working, an agent's archive of a working session is refused through its own channel while the person keeps a simple confirmation, and session.stop is attributed artifact 1

⚪ UNVALIDATED — 2. agents see which sessions are working, an agent's archive of a working session is refused through its own channel while the person keeps a simple confirmation, and session.stop is attributed artifact 2

  • ⚪ UNVALIDATED — no visual expectations recorded.

agents see which sessions are working, an agent's archive of a working session is refused through its own channel while the person keeps a simple confirmation, and session.stop is attributed artifact 2


Test run created 2026-09-11T17:39:16.361Z · Source: evals/results/test-runs/2026-09-11T17-39-16-361Z-agents-see-which-sessions-are-working-an-agent-s-archive-of-a-working-session-is/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4893 --test-run 2026-09-11T17-39-16-361Z-agents-see-which-sessions-are-working-an-agent-s-archive-of-a-working-session-is

@yomgui

yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

For the human approver — state at head 7bd7f33e0:

  • Warden 2AY-HF9 (high, session.stop without confirmation) is the same finding as NLX-3N2 on the previous head and is an explicit product decision (2026-09-11): agents may stop a session when the user asks, at the same trust level as session.create/session.archive; the safeguard is attribution (toast + notification-center entry + control log naming the requesting session), not a gate. No confirmed:true attestation, no cross-session restriction. Clearance therefore cannot self-grant; this needs one human approving review.
  • Warden TW3-UT2 (advisory) points at session-archive-agent-requester.e2e.test.ts:36, but that spec drives the registered action (agent.run("session.list_sessions")) and asserts its output; the direct listControlSessions call it describes lives in the pre-existing session-list-sessions-inventory.test.ts. Advisory only; does not withhold clearance.
  • The two confidentiality findings raised on 3f79fc4ff (session titles in bridged results / stop notifications) were not re-raised on this head; titles here are the user's own sessions shown inside the user's own desktop.
  • Daytona evidence for both e2e specs is published for 7bd7f33e0 (1/1 each, refMismatch: false); all required checks are green.

@yomgui

yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Superseded on 2026-09-11 by a split so the un-gated value can merge today:

Nothing on this branch was rebased, amended or force-pushed; both new branches start from 7bd7f33e0. Daytona evidence for both new heads is being published on the new PRs.

@yomgui yomgui closed this Sep 11, 2026
yomgui added a commit that referenced this pull request Sep 11, 2026
…rough the requester's channel (split of #4893, without session.stop) (#4903)

* fix(app): tell agents which sessions are working and who asked to archive one

An agent archived its own running session from inside its turn: the app
asked the person to confirm Stop and archive, but the bridge mailbox gave
up after 5 s with a generic "window did not answer" error, and the dialog
could not say who had asked.

- session.list_sessions entries and session.read results carry `status`
  and `working` so agents can check before touching a session.
- The Stop-and-archive dialog names the requesting agent session (title and
  id), or "this session itself" when a session asked to archive itself.
- Bridged commands that open a human-only dialog answer at once with the
  structured code awaiting_user_confirmation and a hint naming target and
  requester; the dialog stays open for the person. Action-supplied codes
  and hints now reach the bridge unchanged.
- The mailbox fallback message names the confirmation case.

Signed-off-by: Guillaume Loret <[email protected]>

* feat(app): session.stop control action attributed to the requesting agent

An agent that can start sessions could not stop one. session.stop
{ sessionId } is the Stop button for any loaded session: it aborts the
turn, cancels subtasks and queued messages, and never navigates. Idle
targets return alreadyIdle; unknown ids are a structured error. The
safeguard is attribution: the stop shows "Session stopped: <title>" with
the requesting agent session as a toast and as a notification-center entry
with a View action. Archive semantics are unchanged.

Signed-off-by: Guillaume Loret <[email protected]>

* fix(app): route archive warnings back through the requester's channel

An agent's request must never open a dialog for the person. session.archive
on a working session through the agent bridge now returns a structured
refusal in the agent's own conversation: target_working (stop it first with
session.stop if the user wants it closed, otherwise leave it running) or
self_archive_while_working (finish the turn; the reviewer archives). Idle
targets archive as before. The awaiting_user_confirmation race is gone.

The person's own archive of a working session keeps its confirmation but
simplified to the essentials: the session title, one question, Keep session
open / Stop and archive. The Requested by row and forensic detail are
withdrawn from the dialog; attribution stays on session.stop.

Signed-off-by: Guillaume Loret <[email protected]>

* docs: escape the placeholder in the session.stop notification example for MDX

Signed-off-by: Guillaume Loret <[email protected]>

* fix(app): carry the archive-channel fix without session.stop

Split of #4893: this branch keeps everything Warden can self-clear — status
and working in session.list_sessions / session.read, the agent path of
session.archive that refuses a working target (target_working /
self_archive_while_working) instead of opening a dialog, the simplified
human confirmation, structured code/hint propagation through the bridge,
the mailbox's 5 s message, and the docs. The session.stop control action
(Warden 2AY-HF9: stop by id without confirmation, an explicit product
decision that needs a human approver) is removed here and re-added in a
stacked PR. The target_working hint now sends the agent back to the person
instead of to session.stop.

Signed-off-by: Guillaume Loret <[email protected]>

---------

Signed-off-by: Guillaume Loret <[email protected]>

This branch was successfully deployed

5 active (4 outdated) deployments
staging - packages/docs — 7bd7f33e Deployed Sep 11, 2026 by mintlify[bot]
Preview – openwork-app — 3f79fc4f Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-den — 3f79fc4f Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-diagnostics — 3f79fc4f Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-landing — 83a6cd7d Deployed Sep 11, 2026 by vercel[bot]
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.

1 participant