.
D 2026-11-24T12:43:00.373
L checkin/534501d23ad1c5329fe7d4aaf6fc96b3307bf243d2f36e8ca2e4d1411e50de99
N text/x-markdown
U dmestas
W 1957
# /auth step 1 (#70): each conversation keeps its own model and key
Going on with a conversation uses the model, key and thinking level its last request ran with,
instead of the saved default. Covers `pic -p -c`, `--session`, `--session-id`, `pic ask --session`,
`pic tui -c`, `/resume`, and RPC `--session` and `switch_session`. A fork goes on with its parent's.
`--model` and `--key` still win for one run, and that run becomes the conversation's own.
When the remembered model or key cannot be had (no key for the provider, the named key removed, the
model unknown), `-p` and `ask` stop with one line that names it and the way on, and send nothing.
The TUI says it in one line with the model the next message goes to; RPC says it on stderr.
## How
- No schema change. The choice is read from what the journal already keeps:
`pic_submission.model` and `thinking` of the latest request along the conversation (and the ones
it was forked from), and `pic_generation.credential` of the last reply to that model's provider,
turned back into a label (`default`, a stored label, `env`, `file`).
- `pic_session_choice` (loop.c) answers it; `pic_model_usable` (model.c, core) says whether it can
be had now, using only core calls, so the TUI can ask it too.
- main.c `resume_choice` applies it for `-p` and `ask`; `--key` without `--model` now waits for
the conversation's model before it is checked.
- rpc.c `adopt_choice` on `--session` and `switch_session`, unless `--model` was given
(`pic_rpc_host.model_named`).
- TUI `tui_resume_choice` in `resume()`, from new `pic sessions --json` fields `model`,
`credential` (`provider:label`) and `thinking`.
- keyhealth.c untouched.
## Tests
New `test/pic/sessionmodel.sh` (dev and release; the named-key half dev only), and a TUI case at
the end of `test/tui/lastmodel.sh`.
Tier: root and core (no new file). Clock: durability. Record: the journal's existing request and
reply rows. Default: on.
Z dd4fe3929aa864362ac600b3cf6ddf98