Skip to content

fix(app): agents see working sessions and archive warnings go back through the requester's channel (split of #4893, without session.stop) - #4903

Merged
yomgui merged 5 commits into
devfrom
fix/agent-archive-working-sessions-status
Sep 11, 2026
Merged

yomgui merged 5 commits into
devfrom
fix/agent-archive-working-sessions-status

Conversation

@yomgui

@yomgui yomgui commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Split of #4893 (2026-09-11): this PR carries everything Warden can self-clear. The session.stop control action (Warden 2AY-HF9, an explicit product decision that needs a human approver) is re-added in a stacked follow-up PR; #4893 is closed as superseded by the pair.

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 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 and the control provider hands it to actions as helpers.origin, but session.archive's execute ignored it. The modal 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 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, #4818, #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.

  • 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 } — the hint says: if the user wants it closed, ask them to stop it in the app, then archive once working is false; otherwise 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: "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.
  • The mailbox's 5 s fallback message names the confirmation case (still reachable by window.confirm-gated actions such as session.delete).
  • Docs: cross-chat-memory.mdx gains "How agents manage other sessions" (check status, then archive; stopping stays with the person).

Not in this PR

session.stop { sessionId } (the Stop button for any loaded session by id, no confirmation, attribution as the safeguard). It is the only part of #4893 Warden flagged (2AY-HF9 / NLX-3N2) and it is an explicit product decision the user wants a human to approve, so it lives in its own stacked PR on top of this one. The target_working hint here therefore sends the agent back to the person instead of to session.stop; the stacked PR restores the session.stop wording.

Verification

Head: 5997d8401 (the four #4893 commits + one signed, signed-off commit that removes session.stop).

Command Lane Result
bun test --isolate tests/session-archive-agent-contract.test.tsx tests/notification-store.test.ts (apps/app) Local Exit 0: 15 passed (8 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=5997d8401…) Fresh Daytona Exit 0: 1 passed, 0 failed, 0 skipped; refMismatch: false (evidence comments)
pnpm evals:e2e session-archive-confirmation-identity (same env) Fresh Daytona Exit 0: 1 passed, 0 failed, 0 skipped; refMismatch: false (evidence comments)

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; session.stop is not advertised; the person's own sidebar click shows the simplified confirmation and Keep leaves B running; idle bridged archive completes. session-archive-confirmation-identity covers the simplified dialog, duplicate/blank/long titles, no mutation before consent, and B-only stop with Undo.

…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]>
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]>
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]>
@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, 7:28 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.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 11, 2026 7:27pm UTC
openwork-den Ready Ready Preview Sep 11, 2026 7:27pm UTC
openwork-diagnostics Ready Ready Preview Sep 11, 2026 7:27pm UTC
openwork-landing Ready Ready Preview, v0 Sep 11, 2026 7:27pm UTC

@github-actions

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 1. Blocking policy matches before consolidation: 0. 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 (193582 ms), confidentiality-review (235765 ms), spec-provenance-review (281134 ms), desktop-den-sync-review (317148 ms).

Blockers

  • None.

Advisories

  • GXK-BJ4 · medium · spec-provenance-review · evals/specs/session-archive-confirmation-identity.e2e.test.ts:21

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 1
  • Distinct heads in retained window: 1
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 1/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 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.

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (5997d84015139c1d6058db593cf354c129a0435f). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@different-ai different-ai deleted a comment from github-actions Bot Sep 11, 2026
@yomgui

yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Second test run on this head (copied verbatim from the publisher output so both specs stay visible; the sticky comment below holds session-archive-agent-requester):

Test evidence — busy background archive identifies its captured target before consent and stops only that target — ✅ passed

SHA 5997d84 · sandbox ref 5997d84 · engine v1

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

[world] desktop(daytona) · mock(mcp) · workspace(/tmp/openwork-session-archive-1789155391415-7289-a) · [seed:raw] evalIn() ×27
[agent] run(session.open)
[probe] eventually(owning composer is ready)
[user] type(composer, "Keep Archive other workspace running for confirmation identity 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 confirmation identity proof.", replace) · press(Enter)
[probe] eventually(task reaches held provider) · hash
[user] see(text=This session is still working)
[probe] hash
[user] screenshot
[agent] ❌ run(session.archive)
[user] label=Keep session open · click(label=Keep session open) · notSee(text=This session is still working)
[probe] hash
[agent] run(session.open)
[probe] eventually(title fixture owner is ready)
[agent] run(session.rename)
[user] see(testId=sidebar-session-ses_f6e072d74ffe50IUH2JwKE0cPX, text="Chat A")
[agent] run(session.open)
[probe] hash · eventually(A is visible before background archive)
[user] see(text=This session is still working)
[probe] hash
[agent] ❌ run(session.archive)
[user] label=Keep session open · click(label=Keep session open)
[agent] run(session.open)
[probe] eventually(title fixture owner is ready)
[agent] desktopApi(PATCH /workspace/ws_46af97d2ef8b/opencode/session/ses_f6e072d74ffe50IUH2JwKE0cPX)
[user] see(testId=sidebar-session-ses_f6e072d74ffe50IUH2JwKE0cPX, text="New session")
[agent] run(session.open)
[probe] hash · eventually(A is visible before background archive)
[user] see(text=This session is still working)
[probe] hash
[agent] ❌ run(session.archive)
[user] label=Keep session open · click(label=Keep session open)
[agent] run(session.open)
[probe] eventually(title fixture owner is ready)
[agent] desktopApi(PATCH /workspace/ws_46af97d2ef8b/opencode/session/ses_f6e072d74ffe50IUH2JwKE0cPX)
[user] see(testId=sidebar-session-ses_f6e072d74ffe50IUH2JwKE0cPX, text="New session")
[agent] run(session.open)
[probe] hash · eventually(A is visible before background archive)
[user] see(text=This session is still working)
[probe] hash
[agent] ❌ run(session.archive)
[user] label=Keep session open · click(label=Keep session open)
[agent] run(session.open)
[probe] eventually(title fixture owner is ready)
[agent] run(session.rename)
[user] see(testId=sidebar-session-ses_f6e072d74ffe50IUH2JwKE0cPX, text="Long target unbroken-identityunbroken-identityunbroken-identityunbroken-identityunbroken-identityunbroken-identityunbroken-identityunbroken-identityunbroken-identityunbroken-i
[agent] run(session.open)
[probe] hash · eventually(A is visible before background archive)
[user] see(text=This session is still working)
[probe] hash
[user] see(text=This session is still working)
[probe] hash
[user] screenshot
[agent] ❌ run(session.archive)
[user] label=Keep session open · click(label=Keep session open)
[agent] run(session.open)
[probe] eventually(title fixture owner is ready)
[agent] run(session.rename)
[user] see(testId=sidebar-session-ses_f6e072d74ffe50IUH2JwKE0cPX, text="Archive other workspace")
[agent] run(session.open)
[probe] eventually(A remains visible during confirmation)
[user] see(text=This session is still working)
[probe] hash
[user] label=Stop and archive · click(label=Stop and archive) · see(label=Stopping...)
[probe] eventually(B stop reaches engine boundary) · hash
[agent] run(session.archive)
[user] notSee(text=This session is still working) · see(text=Session archived: Archive other workspace)
[probe] hash · eventually(Undo is ready)
[user] label=Undo · click(label=Undo)
[probe] eventually(Undo restores only B) · hash ×21 · eventually(restoring B never restarts stopped work or navigates away from A)
steps 1 ✅ two independent real tasks run while A remains visible (5.7s) · 2 ✅ programmatic B confirmation names B, remains pending, and Cancel changes neither task (4.2s) · 3 ✅ duplicate, blank or long target remains identifiable (duplicate) (2.4s) · 4 ✅ duplicate, blank or long target remains identifiable (blank) (1.9s) · 5 ✅ duplicate, blank or long target remains identifiable (blank) (1.8s) · 6 ✅ duplicate, blank or long target remains identifiable (long) (2.8s) · 7 ✅ confirmed stop awaits B's engine, preserves A, and Undo restores B without restarting (18.7s)
verdict passed · 18 user observations (see ×14, screenshot ×2, notSee ×2) · 54 probes · steps 7/7

⚪ UNVALIDATED — 1. busy background archive identifies its captured target before consent and stops only that target artifact 1

  • ⚪ UNVALIDATED — no visual expectations recorded.

busy background archive identifies its captured target before consent and stops only that target artifact 1

⚪ UNVALIDATED — 2. busy background archive identifies its captured target before consent and stops only that target artifact 2

  • ⚪ UNVALIDATED — no visual expectations recorded.

busy background archive identifies its captured target before consent and stops only that target artifact 2


Test run created 2026-09-11T19:34:20.873Z · Source: evals/results/test-runs/2026-09-11T19-34-20-872Z-busy-background-archive-identifies-its-captured-target-before-consent-and-stops-/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4903 --test-run 2026-09-11T19-34-20-872Z-busy-background-archive-identifies-its-captured-target-before-consent-and-stops-

@yomgui

yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

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

SHA 5997d84 · sandbox ref 5997d84 · engine v1

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

[world] desktop(daytona) · mock(mcp) · workspace(/tmp/openwork-session-archive-1789154923145-68005-a) · [seed:raw] evalIn() ×22
[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_f6e0e6159ffedKRlRYB62CkL94) · testId=session-archive-ses_f6e0e6159ffedKRlRYB62CkL94 · click(testId=session-archive-ses_f6e0e6159ffedKRlRYB62CkL94) · 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)
steps 1 ✅ two independent real tasks run while A remains visible (7.4s) · 2 ✅ session.list_sessions tells agents which sessions are working before they touch them (0.6s) · 3 ✅ an agent archiving another working session is refused with target_working: no dialog, no stop, no 5 s stall (3.8s) · 4 ✅ a session archiving itself mid-turn is refused with self_archive_while_working, no dialog (3.6s) · 5 ✅ the person's own click keeps a simple confirmation: title, one question, Keep or Stop and archive (9.9s)
verdict passed · 6 user observations (notSee ×4, see ×1, screenshot ×1) · 9 probes · steps 5/5

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

  • ⚪ UNVALIDATED — no visual expectations recorded.

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


Test run created 2026-09-11T19:26:46.623Z · Source: evals/results/test-runs/2026-09-11T19-26-46-622Z-agents-see-which-sessions-are-working-and-an-agent-s-archive-of-a-working-sessio/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4903 --test-run 2026-09-11T19-26-46-622Z-agents-see-which-sessions-are-working-and-an-agent-s-archive-of-a-working-sessio

@yomgui

yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Verification update for head 5997d8401 — verdict Passed:

Command Lane Result
pnpm evals:e2e session-archive-agent-requester (OPENWORK_EVAL_DAYTONA=1 OPENWORK_EVAL_REF=5997d8401…) Fresh Daytona Exit 0: 1 passed / 0 failed / 0 skipped, refMismatch: false — sticky evidence comment
pnpm evals:e2e session-archive-confirmation-identity (same env) Fresh Daytona Exit 0: 1 passed / 0 failed / 0 skipped, refMismatch: false — evidence comment above (a first attempt ran before the branch was pushed and was discarded as refMismatch: true)

Both Daytona sandboxes were created and deleted by the runner. Local: app contract 15/15, server plugin 36/36, session-list-sessions-inventory 4/4, tsc --noEmit clean in apps/app, apps/server, packages/types, git diff --check clean.

This branch was successfully deployed

5 active deployments
staging - packages/docs — 5997d840 Deployed Sep 11, 2026 by mintlify[bot]
Preview – openwork-landing — 5997d840 Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-app — 5997d840 Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-den — 5997d840 Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-diagnostics — 5997d840 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