Skip to content

feat(acp): adopt the cloud agent session lifecycle for resume and close and errors#536

Merged
CSRessel merged 3 commits into
mainfrom
cloud-session-lifecycle
Jul 6, 2026
Merged

feat(acp): adopt the cloud agent session lifecycle for resume and close and errors#536
CSRessel merged 3 commits into
mainfrom
cloud-session-lifecycle

Conversation

@CSRessel

@CSRessel CSRessel commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

🤖 Generated with Nori

  • session/resume support: AcpBackend::resume_session gains a third branch — when the agent advertises sessionCapabilities.resume but not session/load (the nori-cloud contract), reattach via session/resume with no silent session/new fallback (on a cloud agent that would claim a brand-new VM). Branch order: load_session (replay) > session_resume (live reattach) > client-side transcript replay. The shared MCP-registration block was deduped into one helper across the four branches.
  • /close command: capability-gated on sessionCapabilities.close; releases the live session over session/close and starts a fresh chat only on success. While the close is in flight, session-switching commands (/new, /resume, /agent, …) are blocked so the deferred NewSession can't clobber a conversation the user switched to; failures surface via AppEvent::SessionCloseFailed with the enhanced message and unblock the widget.
  • Structured ACP error mapping: categorize_acp_error_chain walks the anyhow chain for the structured acp::Error, maps by JSON-RPC code (-32000 auth_required, -32002 session-not-found, -32010 unreachable (retryable), -32012 not-resumable, -32014 no-active-session, -32015 already-active), code wins over substring heuristics, and surfaces error.data.detail (e.g. the deployment's exact login hint) — used by spawn/resume/close and prompt-failure paths.
  • Picker fixes: the /resume picker's agent-list gate is now session_list && (load_session || session_resume) — cloud sessions actually appear (PR feat(acp): source /resume picker from agent session/list #518's feature was gated off for the one agent that needed it). The cloud sentinel cwd / is hidden from row descriptions and search.
  • Capabilities plumbing: AgentCapabilitiesView gains serde-defaulted session_resume/session_close; mock-acp-agent gains env-gated resume/close handlers + failure switches for tests.

This is the client half of nori-cloud-cli-followup.md (agent/router half landed in nori-sessions PR #1045). Capability-gated throughout — agents that don't advertise the new capabilities behave exactly as before.

Decisions to review / known follow-ups

  • /close = swap, not just release: on success we start a new chat, which (for cloud) immediately claims a fresh VM — consistent with existing /new semantics, but "release and idle" isn't expressible today. Flagging the UX question.
  • /close shows in the slash popup for all agents (gated with an explanation on invoke); wiring it into the disabled_builtin_commands greying mechanism (like /goal) is a clean follow-up.
  • Prompt-path errors show data.detail as raw JSON via {err:#} rather than the curated treatment; cosmetic inconsistency.
  • The runtime CloseSession command arm is covered indirectly (connection tests below, widget tests above, harness close-failure test through close_active_session).

Test Plan

  • TDD: failing tests first (compile-RED for new API, runtime-RED for picker gate/resume branch), then green
  • New coverage: structured categorization unit tests; connection resume/close round-trip + failure tests against the real mock-agent subprocess; harness resume-not-load / no-fallback / enhanced-close-failure / capabilities-projection tests; TUI picker gate (positive + negative), /close ordering + failure + gating tests; /cl slash-popup snapshot
  • cargo test (full workspace) green; cargo test -p tui-pty-e2e green; just fmt + just fix clean
  • Live TUI drive (tmux): /resume shows agent-sourced sessions under the cloud contract → select reattaches via session/resume/close prints "Session closed (released)." and starts a fresh chat
  • Live loop against a real nori-handroll acp --type cloud + broker (needs Sessions auth; verified against the mock contract only)

Share Nori with your team: https://www.npmjs.com/package/nori-skillsets

…, structured errors

The cloud agent (nori-handroll acp --type cloud) advertises
sessionCapabilities.{list,resume,close} with loadSession:false, but the
CLI never called session/resume or session/close, gated the agent-sourced
/resume picker on load_session (hiding every cloud session), and mapped
ACP errors by substring only.

- Project session_resume/session_close into AgentCapabilitiesView
- Reattach via session/resume when load is unsupported; never fall back
  to session/new on a resume failure (it would claim a fresh cloud VM)
- /close: capability-gated release of the live session, new chat only on
  success; session-switching commands blocked while the close is in flight
- Structured error mapping by JSON-RPC code (-32000 auth_required with
  error.data.detail surfaced, -32002/-32010/-32012/-32014/-32015), code
  wins over message heuristics; spawn/resume/close and prompt failures all
  use it
- /resume picker gate is now session_list && (load_session || session_resume);
  the cloud sentinel cwd "/" is hidden from picker rows
- Mock agent gains env-gated resume/close support and failure switches

🤖 Generated with Nori
🤖 Generated with [Nori](https://noriagentic.com)

Co-Authored-By: Nori <contact@tilework.tech>
@CSRessel CSRessel changed the title feat(acp): adopt the agent session lifecycle — session/resume, /close, structured errors feat(acp): adopt the agent session lifecycle for resume, close, errors Jul 6, 2026
CSRessel added 2 commits July 6, 2026 18:48
…0204)

New advisory published against crossbeam-epoch 0.9.18 (invalid pointer
dereference in the fmt::Pointer/Display impls); lockfile-only patch bump
per the advisory's recommended fix. cargo deny check advisories is green
locally.
@CSRessel CSRessel changed the title feat(acp): adopt the agent session lifecycle for resume, close, errors feat(acp): adopt the cloud agent session lifecycle for resume and close and errors Jul 6, 2026
@CSRessel CSRessel merged commit 703770e into main Jul 6, 2026
2 checks passed
@CSRessel CSRessel deleted the cloud-session-lifecycle branch July 6, 2026 23:23
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