brain_session_end
End a session by capturing a summary and next focus, validating revision and blocking accidental focus shrink.
Instructions
End a session from an explicit user command, on judgement alone.
nothing_to_capture_reason is now OPTIONAL. The old rule — a non-empty
ledger XOR a written reason — measured whether the client had DECLARED
its work. Derived capture feeds that signal from the server, and a check
is hollow the moment the thing it checks can influence its own signal;
worse, it made a session whose ledger the server had filled impossible
to close. Give a reason if you have one to give; a blank one is still
refused, because saying nothing and saying " " are not the same act.
What end still requires is what the server cannot produce for you:
a summary and a next focus. It REPORTS unattributed_in_window —
artifacts of this project created during the session that belong to no
ledger — as a measure, never a gate. It cannot refuse a close, and a
session cannot improve it by doing nothing.
For a bound session, expected_focus_revision is the SLOT revision (from
bind, resume, or relay's slot.revision), never started_focus_revision.
For an UNBOUND session, next_focus REPLACES the project's whole base focus
under a compare-and-swap on expected_focus_revision. SHRINK GUARD: a
next_focus under 70% of the current base focus is refused before any write
(base_focus_shrink, current, proposed and floor in the message) and the
session stays open, so carry the durable content over and call again. A bound
end REPLACES the whole slot body and meets the same 70% guard
(slot_focus_shrink). allow_focus_shrink = true requires an active
/brain-admin elevation for this credential and MCP connection; otherwise
focus_shrink_override_refused is raised before any mutation. Shared-token
and stdio callers cannot override; an operator relay can. A stale revision is still
recorded as a conflict and closes the session, since nothing is written.
An agent tracer is the only session the server opens or closes on its own; no hook and no auto-close may invoke this lifecycle boundary.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| summary | Yes | ||
| next_focus | Yes | REPLACES the whole project base focus for an unbound session, or the whole slot body for a bound session. A replacement under 70% of the current length is refused (`base_focus_shrink` or `slot_focus_shrink`), leaving the session open. The override is operator-only: an end requires an active /brain-admin elevation for this credential and MCP connection; an operator relay may also override. Carry all durable judgement and commitments forward, including decisions and deadlines with their reasons. Do not copy measurable state: each briefing recalculates it from its source. | |
| session_id | Yes | ||
| allow_focus_shrink | No | The override is operator-only and requires an active /brain-admin elevation for this credential and MCP connection, checked before any mutation (`focus_shrink_override_refused`). True allows a replacement under 70% of the whole base focus or slot body (`base_focus_shrink` or `slot_focus_shrink`); shared-token and stdio callers cannot override. An operator relay is also permitted. | |
| expected_client_key | Yes | Client identity expected for the addressed session UUID. The pair must match before any session mutation. This is an isolation guard, not authentication. | |
| expected_focus_revision | Yes | ||
| nothing_to_capture_reason | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session | Yes | Persistent state of one explicitly controlled concurrent session. | |
| replayed | Yes | ||
| focus_diff | No | ||
| focus_at_end | Yes | ||
| current_focus | Yes | ||
| focus_outcome | Yes | Persisted outcome of the one focus update attempted while ending. | |
| focus_revision_at_end | No | ||
| current_focus_revision | Yes | ||
| unattributed_in_window | Yes | ||
| remaining_open_session_count | Yes |