Skip to content

feat(app): session.stop by id, attributed to the requesting agent (gated remainder of #4893) - #4907

Open
yomgui wants to merge 10 commits into
devfrom
feat/session-stop-by-id
Open

yomgui wants to merge 10 commits into
devfrom
feat/session-stop-by-id

Conversation

@yomgui

@yomgui yomgui commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

This PR adds session.stop { sessionId }: an agent can stop a loaded, live background session by canonical id without a confirmation dialog. The action refuses pinned sessions, missing sessions, idle sessions, requests without an attributed originating session, and the authoritative person-focused session when the requester is another session; a focused session may stop itself. A successful stop interrupts only the target and records who requested it in a toast and notification-center entry with a View action.

It does not make archive an unconditional stop path, change person-initiated archive confirmation, add permission-reply handling, or add a confirmation/approval flow to the agent stop path. Agent archive behavior remains owned by #4903; this PR keeps stop as a separate explicit action and preserves the finite main-process transport behavior established in #5074.

Context

#4893 originally combined working-session discovery, the safe agent archive request channel, and cross-session stop. After Warden flagged cross-session interruption as the security-sensitive part, discovery and archive behavior shipped separately in #4903 while this stop capability remained here for explicit review. The final implementation retains the approved no-confirmation behavior while adding unattributed, pinned, focused-other-session, missing, and non-running refusals.

Behavior

  • Resolves the stop target from live workspace/session state rather than route hints.
  • Uses the desktop main-process transport to interrupt the target, then verifies that its run settled.
  • Leaves the requester running and does not navigate or steal focus.
  • Refuses the person-focused target when another session requests the stop, but permits the focused requester to stop itself.
  • Persists target and requester attribution in Notifications; View opens the stopped target.
  • Keeps archive target resolution independent from the stricter stop authorization path.
  • Documents the action and its refusal codes for agents.

Design: reuses existing controls and notifications (P5), never auto-navigates (S5), keeps action/result copy consistent (C2), and includes real-size evidence below (P10).

Screenshots

A successful background stop leaves the requester open and shows target and requester attribution in the toast.

Successful background stop: the toast names the stopped target and requesting session and offers View without navigating.

The Notifications panel persists the stopped-session attribution and View action.

Notification Center: the same attribution and View action remain available after the toast.

The pinned background target remains running in the Pinned section after an agent-issued stop is refused.

Pinned refusal: the background target remains in Pinned and keeps running; no stop dialog or interruption occurs. The archive toast is retained from the preceding archive-control step in the same verified journey.

The focused Chat A requester remains running while an agent-issued stop from another session is refused.

Focused refusal: Chat A remains the person-focused running conversation and the background requester cannot stop it. The archive toast is retained from the preceding archive-control step in the same verified journey.

Verification

Final head: f92eba8178aba9d614788cf180401153cdf40e11.

Check Lane Result
session-archive-agent-requester with strict SHA matching Fresh Daytona Electron 1 passed, 0 failed, 0 skipped; sandbox SHA matched
session-archive-pinned with strict SHA matching Fresh Daytona Electron 1 passed, 0 failed, 0 skipped; sandbox SHA matched
session-archive-pressure Isolated local Electron/v1 1 passed, 0 failed, 0 skipped
session-send-pressure Isolated local Electron/v1 1 passed, 0 failed, 0 skipped
Archive deadline, mailbox, transport, and send-isolation specs Local PR lane 4 files passed, 0 failed
Agent stop contract Local Bun 29 passed, 0 failed
Revert-fails pinned guard control Local Bun mutation Guard temporarily removed: 28 passed, 1 failed exactly because ses_pinned stopped successfully instead of returning code: "pinned"; fixed bytes restored and 29/29 reran green
Extension-origin contract Local Bun 101 passed, 0 failed
pnpm typecheck from the repository root Local Passed; the documented root script dispatched the app TypeScript check
Server typecheck Local Passed
pnpm evals:typecheck from the repository root Local Passed; checked 486 evals source files with no errors

The changed composer/model fixture command also reproduces four existing composer-continuity failures on clean base 4e680b82e; both branch and control report 28 passed and the same 4 failed signatures. The repository-documented root commands pnpm typecheck and pnpm evals:typecheck passed locally; the former delegates to the app TypeScript check, while the server typecheck was also run directly. The requester/pinned journeys ran on fresh Daytona Electron at the exact head; the pressure witnesses ran on isolated local source-built Electron because those worlds require runner-reachable loopback pressure.

The feature-owned contracts and exact-head journeys are green. Exact-head sticky evidence publishes the primary Daytona journey. Combined private review publication remains unavailable because the available publisher credential targets a public store rather than the review app's private store; no private evidence was copied to the public store.


Recreated from #4904 after GitHub closed that stacked PR when its base branch was deleted.

…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]>
…gent

Stacked on #4903 (the un-gated half of #4893). Restores the session.stop
control action: the Stop button for any loaded session by id, at the same
trust level as session.create / session.archive, with no confirmation.
Product decision (2026-09-11): the safeguard is attribution, not a gate —
"Session stopped: <title> — Requested by <agent session>" as a toast and a
notification-center entry with a View action, plus the control narration.
Idle -> {ok:true, alreadyIdle:true}; unknown id -> structured error; the
target_working hint points agents at session.stop again.

This is Warden finding 2AY-HF9 (stop by id without confirmation) and is
intentional; it needs one human approving review.

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 17, 2026, 4:32 AM

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5006c1a
Status:🚫  Build failed.

View logs

@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 17, 2026 5:28am UTC
openwork-den Ignored Ignored Preview Sep 17, 2026 5:28am UTC
openwork-diagnostics Ignored Ignored Preview Sep 17, 2026 5:28am UTC
openwork-landing Ignored Ignored Preview Sep 17, 2026 5:28am UTC

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 3. 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 (114233 ms), confidentiality-review (184413 ms), spec-provenance-review (219601 ms), desktop-den-sync-review (255975 ms), design-spec-review (358376 ms).

Blockers

  • None.

Advisories

  • CT6-64Z · low · design-spec-review · apps/app/src/react-app/domains/session/control/session-control-actions.ts:451
  • 9R3-XHV · medium · design-spec-review · apps/app/src/react-app/domains/session/sidebar/use-session-archive.tsx:66
  • L78-9HR · low · design-spec-review

Needs recheck

  • None.

Observed review-thread metrics

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

@different-ai different-ai deleted a comment from github-actions Bot Sep 11, 2026
Signed-off-by: Guillaume Loret <[email protected]>

# Conflicts:
#	apps/app/src/react-app/domains/session/sidebar/use-session-archive.tsx
#	apps/app/tests/session-archive-agent-contract.test.tsx
#	packages/docs/start-here/do-work-with-it/cross-chat-memory.mdx
@vercel
vercel Bot temporarily deployed to Preview – openwork-den September 17, 2026 04:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics September 17, 2026 04:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing September 17, 2026 04:45 Inactive
@yomgui

yomgui commented Sep 17, 2026 •

Copy link
Copy Markdown
Member Author

Human-grade review (agent-assisted)

Reviewed the final signed head f92eba817 after merging current dev and against the requested stop-by-id contract.

  • Authorization: stop requires a canonical target plus attributed requester, and refuses pinned, missing, unknown, non-running, and person-focused targets requested by another session; the focused requester may stop itself. The agent path intentionally has no confirmation or permission-reply flow.
  • Isolation: interruption stays on the desktop main-process transport, targets only the requested session, verifies settlement, and leaves the requester running without navigation.
  • Attribution: the toast and persisted notification name the target and requester; View opens the stopped target only when a person chooses it.
  • Regression safety: archive again uses its established route-aware resolver; stop alone uses the stricter live target resolver.
  • UI review: the PR body now shows the success toast, persisted notification, pinned refusal state, and focused refusal state from isolated Electron runs; the final-head Notification Center frame is healthy at 1180×820.

Verification on the final head: exact-SHA Daytona requester and pinned journeys passed 1/1 each with no skips or ref mismatch; local native Electron archive/send pressure passed 1/1 each because those worlds require runner-reachable loopback; four PR-lane contracts passed; targeted app/server tests passed 29/29 and 101/101. The repository-documented root commands pnpm typecheck (which dispatches the app TypeScript check) and pnpm evals:typecheck passed locally; the latter checked 486 evals source files, and the server typecheck also passed directly.

The pinned guard also has a revert-fails control: temporarily removing only that guard made the targeted contract red at 28 pass / 1 fail because ses_pinned stopped successfully instead of returning code: "pinned"; restoring the exact bytes returned it to 29/29 green with a clean tree. One broader changed-fixture command remains red only on four composer-continuity cases that reproduce identically on clean base 4e680b82e (28 pass / 4 fail on both).

Exact-head sticky evidence · resolved Warden security thread · final-head approval by diff-warden on f92eba8178aba9d614788cf180401153cdf40e11; unresolved review threads: 0.

A combined private review report could not be uploaded because the available Blob credential is for a public store rather than the review app's private store. No private evidence was copied to the public store; only approved public UI screenshots and the primary sticky evidence are public.

@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 (f92eba8178aba9d614788cf180401153cdf40e11). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@yomgui

yomgui commented Sep 17, 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 f92eba8 · sandbox ref f92eba8 · engine v1

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

[world] desktop(daytona) · [seed:raw] evalIn() · mock(mcp) · workspace(/tmp/openwork-session-archive-1789623278568-21666-a) · [seed:raw] evalIn() ×25
[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_f5223d92cffe2CYgkV7oJaPLrA) · testId=session-archive-ses_f5223d92cffe2CYgkV7oJaPLrA · click(testId=session-archive-ses_f5223d92cffe2CYgkV7oJaPLrA) · 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] run(session.pin) · desktopApi(POST /experimental/ui-control/request)
[probe] hash
[user] screenshot
[agent] run(session.pin) · desktopApi(POST /experimental/ui-control/request)
[probe] hash
[user] screenshot
[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_f5223d9caffeisyC8aoE4BqBQV) · screenshot
[probe] storage(openwork:notifications:v1)
[agent] desktopApi(POST /experimental/ui-control/request) ×2
[user] label=Notifications (1) · click(label=Notifications (1)) · see(text=Requested by The agent in "Chat A" ses_f5223d9caffeisyC8aoE4BqBQV) · see(testId=notification-action-ntf_mu53ihqd_a3x5z7) · screenshot · testId=notification-action-ntf_mu53ihqd_a3x5z7 · click(testId=notification-action-ntf_mu53ihqd_a3x5z7)
[probe] hash · eventually(notification View opens the stopped target)
[user] notSee(text=This session is still working)
steps 1 ✅ two independent real tasks run while A remains visible (6.2s) · 2 ✅ session.list_sessions tells agents which sessions are working before they touch them (2.4s) · 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.5s) · 6 ✅ a pinned background session refuses the agent-issued stop without confirmation or interruption (1.8s) · 7 ✅ the authoritative focused route refuses another session's stop request (0.8s) · 8 ✅ an agent stops a live background session by id: its run ends, nothing navigates, and the toast names target and requester (10.4s)
verdict passed · 16 user observations (notSee ×6, see ×5, screenshot ×5) · 16 probes · steps 8/8

⚪ 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

⚪ UNVALIDATED — 3. 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 3

  • ⚪ 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 3

⚪ UNVALIDATED — 4. 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 4

  • ⚪ 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 4

⚪ UNVALIDATED — 5. 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 5

  • ⚪ 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 5


Test run created 2026-09-17T05:32:33.402Z · Source: evals/results/test-runs/2026-09-17T05-32-33-401Z-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 4907 --test-run 2026-09-17T05-32-33-401Z-agents-see-which-sessions-are-working-an-agent-s-archive-of-a-working-session-is

This branch was successfully deployed

2 active (outdated) and 3 inactive (outdated) deployments
Preview – openwork-app — bf667770 Deployed Sep 17, 2026 by vercel[bot]
Preview – openwork-landing — bf667770 Deployed Sep 17, 2026 by vercel[bot]
Preview – openwork-den — bf667770 Deployed Sep 17, 2026 by vercel[bot]
Preview – openwork-diagnostics — bf667770 Deployed Sep 17, 2026 by vercel[bot]
staging - packages/docs — 5006c1ac Deployed Sep 17, 2026 by mintlify[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