Skip to content

fix: persist metadata for imported sessions, and list config keys in config get --help - #892

Merged
huichen merged 3 commits into
mainfrom
fix/session-persist
Oct 2, 2026
Merged

huichen merged 3 commits into
mainfrom
fix/session-persist

Conversation

@huichen

@huichen huichen commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

What

Two fixes plus the documentation, found by auditing every command the
future-self skill names against a real agent.

1. fix(agent): session metadata never persisted for imported sessions

future session set --title/--thinking on a legacy-imported session printed
"Updated" and persisted nothing:

Failed to persist session name: Query returned no rows

update_session_info_fields read the newest session_info entry as its merge
base, but the legacy importer never synthesises one — it inserts only the
conversation entries the JSONL held, so query_row found no row.

The entry was the wrong base anyway: entry_records is a view that projects
a session_info entry's content from sessions.current_metadata_json
(agent/src/session/records.rs, VIEWS), so the table column is the
authoritative copy and reading the entry only added a dependency on something
that need not exist. The three cases are now kept distinct:

case result
no row error naming the session — the append would fail on its FK anyway
NULL column empty object — nothing recorded yet, the legacy-import case
non-object JSON error, as before — corrupt metadata, and silently replacing it would drop every other field it held

The third arm is not hypothetical: collapsing it into the empty-object default
while developing this silently swallowed the corruption two existing tests
inject, which is how it was caught.

Left alone deliberately: reporting. A durable-write failure is still logged
rather than returned, and set_thinking_level documents that choice ("predates
fallible RPC setters, so report a durable error without changing its public
signature") with a test pinning it. Changing it would alter client-visible
behaviour for the TUI and Desktop — a separate decision.

Regression test reproduces the exact shape the importer produces (conversation
entries, no session_info) and fails with "Query returned no rows" without the
fix.

2. fix(cli): config get --help didn't list the keys it's pointed at

Two other help texts send readers there — config set --help says "Run future config get --help for the settable keys" — but only config --help actually had
them, so following the pointer produced a page with no keys. The list now lives
where it is pointed at, with accepted values and the "when does it take effect"
table.

A test asserts every key in the command's own KEYS table appears in both help
texts and that the pointer still exists, so they cannot drift apart again;
verified by deleting a key from one text and watching it fail.

3. docs(self) + skill: coverage the audit showed was missing

Skill → futuregene/future-skills#66
(future-self v1.4.0), which corrects two claims that were simply wrong:

  • future session set <id> --tools read,shell does not exist — --tools is
    a future run flag, and the persistent per-session set is an RPC the TUI and
    Desktop call. An agent following the old text would have promised a tool change
    it cannot make.
  • future session list --json was described as carrying "usage"; it carries none
    (tokens/cost are in session info <id>).

And fills gaps the skill depended on but never explained: which session am I
(the isStreaming: true row — verified against a live run), session rename,
asynchronous session compact, list ordering, and the never-run case.

How the coverage was verified

Every command the skill names, run against an isolated FUTURE_HOME on a fresh
port with sessions seeded via --migrate-sessions (no model calls, no cost):
65 assertions, all passing, including the documented argument-rejection
boundaries and the byteOffset → get --offset handoff. isStreaming was
verified with a local OpenAI-compatible endpoint that accepts and never answers,
so a run could be held open without credentials or spend.

Scoped checks

cargo fmt -p future-agent -p future-cli --check          ok
cargo clippy -p future-agent -p future-cli --all-targets -- -D warnings
cargo test -p future-agent -p future-cli                 2094 / 780 pass
python3 scripts/docs/check-docs.py                       251 docs OK
(cd skills && python3 tests/check_builtin.py)            PASS: 16 builtin entries

Not changed (flagging, not fixing)

future auth credential prints "Not logged in." and exits 0 when logged out
— pinned by unit tests and a 1:1 port of the retired TS CLI, so scripts must read
the payload rather than the status. Debatable for a scripting command, but
changing it is a product decision.

…nfo entry

`future session set --title/--thinking` on a legacy-imported session printed
"Updated" and persisted nothing; the agent log showed

    Failed to persist session name: Query returned no rows

`update_session_info_fields` read the newest `session_info` entry to use as its
merge base, but the legacy importer never synthesises one — it only inserts the
conversation entries the JSONL contained. `query_row` therefore found no row and
failed with a bare "Query returned no rows".

The entry is not the right base anyway: `entry_records` is a *view* that
projects a `session_info` entry's content from `sessions.current_metadata_json`
(`records.rs` `VIEWS`), so the table column is the authoritative copy and
reading the entry only added a dependency on something that need not exist. The
base is now that column, with the three cases kept distinct:

     no row          -> error, naming the session: the append would fail on its
                        foreign key anyway, so surface the real cause
     NULL column     -> empty object: nothing recorded yet, which is exactly the
                        legacy-import case being fixed
     non-object JSON -> error, as before: this is corrupt metadata, and silently
                        replacing it would drop every other field it held

That third arm is not hypothetical: collapsing it into the empty-object default
while developing this change silently swallowed the corruption two existing
tests inject ("session has no session_info object"), which is how it was caught.

Reporting is deliberately left alone. A genuine durable-write failure is still
logged rather than returned, and `set_thinking_level` documents that choice
("predates fallible RPC setters, so report a durable error without changing its
public signature") with a test pinning it — changing it would alter client-visible
behaviour for the TUI and Desktop, which is a separate decision.
Two other help texts send readers to `future config get --help` for the keys —
`config set --help` says "Run `future config get --help` for the settable keys",
and the main `config --help` advertises the same — but only `config --help`
actually contained them, so following the pointer gave a page with no keys on it.
Found by auditing every command the `future-self` skill documents against a real
agent, which is also what the skill promises this page contains.

The list now lives where it is pointed at, including the accepted values and the
"when does it take effect" table. A test asserts every key in the command's own
`KEYS` table appears in both help texts and that the pointer still exists, so the
two cannot drift apart again; verified by deleting one key and watching it fail.
…set gap

Fills in the guide for what the audit found, so the repo-side documentation
matches the skill:

- **Finding your own session**: the row with `isStreaming: true` is the session
  executing the turn (verified against a real run), and nothing in the
  environment carries the id — the `shell` tool has no `$FUTURE_SESSION_ID`.
- `session rename` and asynchronous `session compact --session <id>` alongside
  `session set`.
- `session list` returns rows newest-first and its summary deliberately holds no
  usage; tokens and cost are in `session info <id>`.
- The two gaps worth knowing: a session's tool set has **no** CLI switch
  (`--tools` is a `future run` flag; the persistent per-session set is an RPC),
  and a never-run session stores a title/cwd change only when it first runs.

Skills pointer -> futuregene/future-skills#66 (future-self v1.4.0).
@huichen
huichen enabled auto-merge (squash) October 2, 2026 10:47
@huichen
huichen merged commit 1952b65 into main Oct 2, 2026
12 checks passed
@huichen
huichen deleted the fix/session-persist branch October 2, 2026 10:54
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