Skip to content

feat(cli): observe, configure and control a session from the terminal - #897

Merged
huichen merged 1 commit into
mainfrom
feat/session-control
Oct 3, 2026
Merged

huichen merged 1 commit into
mainfrom
feat/session-control

Conversation

@huichen

@huichen huichen commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

What

future session info reads the persisted journal, and session set reached only five options. So a headless caller could start a run and then had no way to see how the session was configured, stop it, or answer an approval it was parked on. This closes those gaps — mostly by wrapping RPCs the TUI and Desktop already used.

Observation

  • future session status <id> [--json] [--metrics] reads get_state: effective tool permission, sandbox tier, context occupancy, loaded context files and skills, active/queued runs, pending approvals. A session pinned to workspace while the global default is all, or at 40% context while having spent 40M tokens lifetime, is only answerable here.
  • session transcript now carries each entry's run outcome and token usage, and --runs prints a one-row-per-run ledger. --counts gained run-status and token sections.

Configuration

session set gained the live-session group — --tools, --no-tools, --no-builtin-tools, --system-prompt, --append-system-prompt, --permission, --sandbox, --context-files, --auto-compact, --auto-retry — each validated client-side, scoped to the target session, and readable back with session status. Contradictory tool options are rejected in either order.

Control

future session abort|cancel|approvals|approve|reject — the CLI counterpart of the TUI's /stop, /cancel, /approve, /reject. approve --allow <glob> installs the standing rule before the decision (so the approved tool already sees it) and, if the decision then fails, says so rather than hiding the permission it left standing.

Lifecycle

session new|fork|forks|clone|title|export. new returns deliberately — #774 dropped it because "a create path whose result no command consumes", and that premise is now gone. title is a model call, so it prints the suggestion and only renames with --apply.

Wire contract

SessionState gained optional string sandbox_tier = 41. --sandbox was write-only: the agent stored the policy and nothing read it back, so a caller could never tell an explicitly chosen tier from the default. Absent means "no policy set", which is different from off. Additive and optional, so an older agent simply omits it.

Two bugs found and fixed while testing

  • --counts silently truncated at the 256 KiB output budget (84 of 529 entries on a real session). Summaries now cover the whole session unless --max-bytes is passed, and a cut says to raise it instead of pointing at --cursor, which the summaries reject.
  • approve --allow could leave a standing permission with no indication when the decision failed.

Testing

  • cargo test -p future-rpc / -p future-cli / -p future-agent — 135 + 872 + 2094 pass (34 new transcript, 22 new session, 11 new status, 6 new rpc tests)
  • cargo fmt --all --check; cargo clippy -p future-rpc -p future-cli -p future-tui --no-deps --all-targets -- -D warnings clean. The full-workspace clippy run shows two pre-existing nonminimal_bool hits in agent/src/session/compaction_ops.rs and channels/src/feishu/feishu_rest.rs — both untouched by this branch, and both a known false positive of the locally-shadowing clippy 1.96 (CI's pinned 1.97 passes); git diff origin/main on those files is empty.
  • make generate-proto is idempotent (identical hash across runs) and leaves channels/src/generated/feishu_ws.rs untouched.
  • python3 scripts/docs/check-docs.py (+ --strict-pending), check-channel-matrix.py
  • Live, isolated agent (--home /tmp/... --grpc-addr 127.0.0.1:5198x, never the user's): new → set (every live option) → status reflects them → --no-tools → abort with nothing running → cancel unknown run → approvals → forks → fork without --entry → clone → title (no provider: fails cleanly) → export (real HTML written) → unknown session.
  • Sandbox read-back: unset → (default) with the key absent; manual/sandbox/off each read back through the CLI, the --json form and raw grpcurl.
  • Backward compatibility: the new CLI against the user's old running agent reads Sandbox: (default) rather than failing.

`future session info` reads the persisted journal and `future session set`
reached only five options, so a headless caller could start a run and then had
no way to see how the session was configured, stop it, or answer an approval it
was parked on. This closes those gaps, mostly by wrapping RPCs the TUI and
Desktop already used.

Observation
- `future session status <id> [--json] [--metrics]` reads `get_state`: the
  effective tool permission, the sandbox tier, context occupancy
  (tokens/window/percent, as opposed to `session info`'s lifetime totals), the
  loaded context files and skills, active/queued runs and pending approvals.
  A session pinned to `workspace` while the global default is `all` is only
  answerable here; `config get` and `session info` cannot express it.
- `session transcript` now carries every entry's run outcome and token usage,
  and `--runs` prints a one-row-per-run ledger (status, duration, tokens,
  error). `--counts` gained run-status and token sections.
- `--counts`/`--runs` cover the whole session by default: the byte budget only
  applies when the caller asks for it, so a distribution is never quietly
  partial. A cut now says to raise `--max-bytes` instead of pointing at
  `--cursor`, which the summaries reject.

Configuration
- `session set` gained the live-session group: `--tools`, `--no-tools`,
  `--no-builtin-tools`, `--system-prompt`, `--append-system-prompt`,
  `--permission`, `--sandbox`, `--context-files`, `--auto-compact`,
  `--auto-retry` — each validated here, each scoped to the target session, and
  readable back with `session status`. `--tools` and the two disable switches
  are mutually exclusive whichever order they arrive in.

Control
- `future session abort|cancel|approvals|approve|reject` — the CLI counterpart
  of the TUI's `/stop`, `/cancel`, `/approve` and `/reject`. `approve --allow
  <glob>` installs the standing rule *before* the decision (so the approved
  tool already sees it) and, if the decision then fails, says so rather than
  hiding the permission it left standing.

Lifecycle
- `session new|fork|forks|clone|title|export`. `new` returns deliberately: #774
  dropped it because "a create path whose result no command consumes", and that
  premise is now gone — `session set` configures and `session status` reads the
  session back. `title` is a model call, so it prints the suggestion and only
  renames with `--apply`; its language defaults to the desktop app's
  `titleLanguage`.

Wire contract
- `SessionState` gained `optional string sandbox_tier = 41`. `--sandbox` was
  write-only: the agent stored the policy but nothing read it back, so a caller
  could never tell an explicitly chosen tier from the default. Absent means "no
  policy set", which is not the same as `off`. Additive and optional, so an
  older agent simply omits it (verified against the running one).

Docs updated in both languages (self-inspection, session-history, the CLI wiki).
@huichen
huichen enabled auto-merge (squash) October 3, 2026 13:04
@huichen
huichen merged commit fb62f47 into main Oct 3, 2026
12 checks passed
@huichen
huichen deleted the feat/session-control branch October 3, 2026 13:13
huichen added a commit to futuregene/future-skills that referenced this pull request Oct 3, 2026
`future session info` reads the journal and `session set` reached five options,
so the skill had no answer for "how is this session configured right now", "stop
it" or "it is waiting on an approval". futuregene/future-os#897 added those, and
this teaches them:

- `future session status <id> [--json] [--metrics]` — the live view: effective
  permission, sandbox tier, context occupancy, context files, loaded skills,
  runs and pending approvals. §2 now says explicitly that `info` and `status`
  answer different questions, because the two are easy to confuse and the wrong
  one gives a confidently wrong answer (a session at `workspace` while
  `config get` says `all`).
- `session set`'s live-session group (`--tools`, `--no-tools`,
  `--no-builtin-tools`, `--system-prompt`, `--append-system-prompt`,
  `--permission`, `--sandbox`, `--context-files`, `--auto-compact`,
  `--auto-retry`), all readable back with `status`.
- `abort` / `cancel` / `approvals` / `approve` / `reject`, with `--allow`.
- `session new|fork|forks|clone|title|export`, noting that `title` is a model
  call and that `new` stays out of `session list` until its first run.
- `transcript`: per-entry run outcome and usage, `--runs`, and that the
  summaries cover the whole session by default.

Also corrects two now-stale claims (the tool set *is* settable from the CLI, and
reasoning *is* reachable via `transcript --select thinking`) and drops the
"would reject the flag" wording.

Version 1.6.0 -> 1.7.0.
huichen added a commit to futuregene/future-skills that referenced this pull request Oct 3, 2026
…70)

`future session info` reads the journal and `session set` reached five options,
so the skill had no answer for "how is this session configured right now", "stop
it" or "it is waiting on an approval". futuregene/future-os#897 added those, and
this teaches them:

- `future session status <id> [--json] [--metrics]` — the live view: effective
  permission, sandbox tier, context occupancy, context files, loaded skills,
  runs and pending approvals. §2 now says explicitly that `info` and `status`
  answer different questions, because the two are easy to confuse and the wrong
  one gives a confidently wrong answer (a session at `workspace` while
  `config get` says `all`).
- `session set`'s live-session group (`--tools`, `--no-tools`,
  `--no-builtin-tools`, `--system-prompt`, `--append-system-prompt`,
  `--permission`, `--sandbox`, `--context-files`, `--auto-compact`,
  `--auto-retry`), all readable back with `status`.
- `abort` / `cancel` / `approvals` / `approve` / `reject`, with `--allow`.
- `session new|fork|forks|clone|title|export`, noting that `title` is a model
  call and that `new` stays out of `session list` until its first run.
- `transcript`: per-entry run outcome and usage, `--runs`, and that the
  summaries cover the whole session by default.

Also corrects two now-stale claims (the tool set *is* settable from the CLI, and
reasoning *is* reachable via `transcript --select thinking`) and drops the
"would reject the flag" wording.

Version 1.6.0 -> 1.7.0.
huichen added a commit that referenced this pull request Oct 3, 2026
future-skills#70 teaches future-self the session status/control/lifecycle
commands added in #897 (future session status, session set's live options,
abort/cancel/approvals/approve/reject, new/fork/clone/title/export, and the
transcript run ledger), so the installed skill matches the CLI beside it.
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