Skip to content

refactor(cli): one session provider for every face (#428, 1/3) - #430

Merged
ajianaz merged 1 commit into
developfrom
refactor/session-provider
Oct 26, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/session-provider

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

What

Adds tole_cli::turn_runner and moves every face's provider construction onto it. Part 1 of 3 of #428.

Why

Six places built the provider for a session turn (run, resume, chat, missions, serve/ACP run and resume) and they had drifted. Only the server faces applied the session's durable fact/model register (the ACP model picker, #176), so a session whose model was switched in ACP silently ran on TOLE_MODEL when resumed with tole resume or tole chat --resume. The server faces' missing-config error also had a run of spaces inside it (a broken string continuation).

Changes

  • turn_runner.rs (new):
    • MISSING_PROVIDER_CONFIG and provider_config(): one wording, used by every face.
    • session_model(storage, default): the fact/model register (trimmed, non-blank) over the default.
    • configure_provider(p, specs, system_prompt, observer): tool specs, the pinned system prompt, ACP's live text/reasoning sinks.
    • session_provider(...): the failover chain (provider failover chain — reserve provider for mission resilience #209) with every link configured that way.
  • main.rs (run, resume, chat), mission.rs and session_host.rs (run and resume) use it. configure_mission_provider is gone; its regression test now exercises configure_provider.
  • CHANGELOG (Fixed + Changed).

Testing

  • New e2e session_model_e2e (real binary, mock provider echoing the requested model): tole resume and tole chat --resume on a session with fact/model = picked-model send picked-model. Both fail on the old main.rs and pass with this change.
  • Unit tests: the register wins over the default and blank falls back; the missing-config message has no run of spaces.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, bare-profile clippy (none / shell-tools), cargo test --workspace: all green on a clean build of this exact commit.
  • Cora agent-as-reviewer on the exact staged diff (review_prepare → own review → review_finalize): should_block: false, no issues. The one info hit was specs.clone() inside the failover closure, which is needed per chain link.

Note: two earlier local runs had failures caused by the machine (a full disk breaking the linker, then heavy IO from cleanup); a clean re-run on an idle machine is fully green. The flaky config_sensitive hook tests are tracked separately in #429.

tole_cli::turn_runner builds the provider for a session turn: env config with one missing-config message, the session's durable fact/model register over the default, the registry's tool specs, the pinned system prompt and the optional live-token sinks. run, resume, chat, missions and the server faces use it instead of six copies. Fixes tole resume / tole chat --resume / resumed missions ignoring a model picked in ACP, and the run of spaces inside the server faces' missing-config error.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 33d08b8 into develop Oct 26, 2026
16 checks passed
@ajianaz
ajianaz deleted the refactor/session-provider branch October 26, 2026 08:11
ajianaz added a commit that referenced this pull request Oct 26, 2026
## What

The memory loop's pre-turn recall injection and session remember move
into `turn_runner`, used by every face. Part 2 of 3 of #428.

## Why

The CLI (`HostConfig::inject_memory` / `remember`) and the session host
each had their own copy. The session host's remember dropped its result
silently, so a failing store on `tole serve` / ACP went unnoticed.

## Changes

- `turn_runner::with_recalled_memory(memory, prompt)`: the prompt with
the recalled block appended; no memory, nothing recalled, or a failed
recall (stderr note, #384) gives the bare prompt.
- `turn_runner::remember(memory, session_id, first_prompt, last_answer,
wrote)`: best-effort summary, reported on stderr either way;
`first_prompt` is the pre-injection prompt, so recalled memory is never
echoed back into the store.
- `main.rs`: `HostConfig::inject_memory` / `remember` delegate to them.
- `session_host.rs`: the first-turn recall and the per-turn remember use
them; the `first_prompt_done` lock is released before the recall
subprocess runs.
- CHANGELOG.

## Testing

- New unit tests with fake `uteke` binaries: a hit is appended, an empty
result and a failing binary both leave the bare prompt; remember stores
the pre-injection prompt in the room (`--room`, `--type decision` for a
write session); no memory is a no-op.
- `cargo fmt`, `cargo clippy --workspace --all-targets -- -D warnings`,
bare-profile clippy (none / shell-tools), `cargo test --workspace`: all
green; rebased onto #430 and rebuilt.
- Cora agent-as-reviewer on the exact staged diff: `should_block:
false`, 0 issues (deterministic hits were `bug-println` on the intended
stderr reporting and `bug-expect` on the existing lock pattern, both
ignored by `.cora.yaml`).

Co-authored-by: ajianaz <[email protected]>
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