Skip to content
pi-c Changes To checkin/534501d23ad1c5329fe7d4aaf6fc96b3307bf243d2f36e8ca2e4d1411e50de99
Login

Changes To checkin/534501d23ad1c5329fe7d4aaf6fc96b3307bf243d2f36e8ca2e4d1411e50de99

Initial version of "checkin/534501d23ad1c5329fe7d4aaf6fc96b3307bf243d2f36e8ca2e4d1411e50de99"



































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# /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.