Repository navigation
feat(cli): add future session new with parent/title/cwd/model/thinking - #771
Merged
Merged
Conversation
Create a session from the CLI with the same knobs the agent's new_session
command already accepts:
future session new [--parent <id>] [--title <name>] [--cwd <dir>]
[--model <id>] [--thinking <level>] [--json]
--parent records lineage and is validated against list_sessions first, so a
typo fails with "Session not found: <id>" instead of leaving a dangling
parentSessionId. --json prints the created session for scripting; the text
mode prints the new session ID, which `future run --session <id>` accepts.
RunClient::new_session keeps its cwd-only signature and delegates to the new
new_session_with(NewSessionOptions).
huichen
enabled auto-merge (squash)
September 22, 2026 05:29
huichen
added a commit
that referenced
this pull request
Sep 22, 2026
`future session new` (#771) creates a session; this adds the command that actually changes an existing one: future session set <id> [--parent <id>] [--title <name>] [--cwd <dir>] [--model <id>] [--thinking <level>] [--json] Agent: new `set_parent_session` command — the one setting the wire contract lacked. It updates the live session and persists `parent_session_id` into session_info, because the run-end snapshot re-reads the parent from disk: an in-memory-only change would be reverted by the next run. It rejects a self-parent and a parent that is neither live nor stored (a live session with no entries yet is a valid parent), and is registered in `command_policy`, which is also the dispatcher's command registry. CLI: the options are applied one at a time and reported. A per-field failure (a model the agent refuses, say) does not roll back the others — it prints `Failed to set <field>: …` and exits 1. `--parent` is applied first and aborts the rest, since a typo there makes the rest of the update meaningless. An empty `--parent` detaches in `set` and now means "unset" in `new` too. `session new` and `session set` share one options struct + parser. The session golden-help test and docs/wiki/{en,zh}/CLI.md are updated.
huichen
added a commit
that referenced
this pull request
Sep 22, 2026
`future session new` (#771) turned out to be a solution to a problem nobody had: it only created a session (`new_session` + print the id) without running anything, while the actual request was to change an existing one — which is `future session set` (#773). Keeping both meant two commands with overlapping option surfaces and a create path whose result no command consumes (`future run --session <id>` also creates the session it is given). Removed: the `new` subcommand, `SESSION_NEW_HELP`, `RunClient::new_session_with` and `NewSessionOptions` (the plain `new_session(cwd)` used by the run orchestration is untouched, and the session options parser now serves `set` alone). The agent-side `set_parent_session` stays — `session set` needs it. A session can still be created without a token: it just isn't a CLI command, matching how every other client does it (they create on first prompt).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
future session newsubcommand that creates a session and lets the caller set the parameters the agent'snew_sessionalready accepts:Text mode prints
Created session <id>plus the options that were set; that ID is whatfuture run --session <id>accepts. Unset options keep the agent's defaults (default workspace → the CLI sends the current directory, likefuture run; default model; agent-preferred thinking level).Details
--parentrecords lineage and is validated first againstlist_sessions— the agent storesparentSessionwithout checking it, so a typo would otherwise leave a danglingparentSessionId. A missing parent fails withSession not found: <id>(exit 1) and never creates a session. Membership is checked on the session list (whatfuture session listshows) rather thanget_session_entries, which answers an unknown ID with a confusing "pass a valid session_id" error.--thinkingis validated against the same level list asfuture run(run::VALID_THINKING_LEVELS, nowpub(crate)), with the same error text.future run's parser, bad input here is a hard error (exit 1) rather than a silently ignored flag.RunClient::new_session(cwd)keeps its signature and now delegates to the newnew_session_with(NewSessionOptions); the one-shotrunpath is unchanged.help.rsgroup line anddocs/wiki/{en,zh}/CLI.mdupdated.Verification
cargo test -p future-cli— 743 lib + 15 integration tests pass (new parser/mock tests: full option round-trip on the wire,created_by: "cli", parent-not-found aborts beforenew_session,--jsonshape, missingsessionId, help without an agent).cargo fmt --check+cargo clippy -p future-cli --all-targets -- -D warnings(clippy run with--no-deps: the local clippy component here is 0.1.96 and false-reports pre-existing lints infuture-agent/future-channel; those crates are untouched by this PR).future agent --home /tmp/… --grpc-addr 127.0.0.1:49187):get_stateconfirmssessionName/cwd/thinkingLevel/createdBy: "cli"are applied; a child created with--parent <persisted id>shows thatparentSessionIdinsession list --jsonafter the child is persisted.Notes
Like the TUI/desktop paths,
new_sessionis live in the agent immediately but only reachesagent.dbonce the session has entries — so a brand-new session shows up infuture session listafter its first prompt.