Skip to content

feat(serve): choose a profile per session on create and resume (#740) - #885

Merged
ajianaz merged 4 commits into
developfrom
feat/740-serve-session-profile
Nov 17, 2026
Merged

ajianaz merged 4 commits into
developfrom
feat/740-serve-session-profile

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What

tole serve accepts an optional profile on POST /sessions, for create and for resume. It selects one [profiles.<name>] table of the user config for that session: persona, allow list, memory room and model. A session without profile is exactly as before.

Refs #740 (two items remain: the tole sessions list profile column and the tole doctor serve-profiles line).

Why

One daemon should host several personas (#740). Owner decisions of 2026-11-16:

  • (a) The profile is chosen at create and resume only, and is fixed for the life of the session process.
  • (b) On resume the request's profile wins over the recorded one, and the session log records the profile used as a new entry (a fact/profile register; nothing is mutated).
  • (c) Budget: [profiles.*] has no budget field today, so none was invented; the server's existing budget logic applies.
  • (d) A request may not set memory_room: it is refused with a 400, create and resume. The room comes from the profile only.
  • (e) Model: the profile's default-tier model if it sets one, else the server default.

Allow list precedence (the same rule --profile has on the CLI, from config/apply.rs): an --allow flag on the tole serve command line pins the daemon's list and the profile's allow is ignored, so a profile never widens it. Otherwise a profile that sets allow replaces the daemon's config/env list, and one that sets none leaves it. --trust presets are added in every case. Every approval still goes through the approval queue.

Escalation analysis: selecting a profile needs the existing bearer token, and no auth is added here. A token holder may pick any user-config profile, including the widest one. That is acceptable under the current model, because the token already grants approval authority; per-profile authorization waits for #742. Only the user config is read (a project config cannot define profiles), and it is re-read on every selection. Profile names are validated to [a-z0-9_-]{1,64} before any lookup, so a hostile name never reaches a message, path or log.

Residuals: skills, grants, the advisor, the router and child agents stay process-wide on this face. Child agents, the advisor and the router use the daemon's model, because tool_roster.rs still reads the global provider config. Not done from the issue: the tole sessions list profile column and the tole doctor serve-profiles line.

Changes

  • serve_support/profiles.rs (new): profile selection from the user config, the allow precedence, the memory-room mapping, and the register helpers.
  • serve.rs: parses profile, refuses memory_room, reconciles on resume, and records the profile. GET /sessions shows profile only when set.
    • Unknown or malformed name: 400. Unloadable profile: 500.
    • Live session asked for another profile: 409.
    • Recorded profile removed or malformed, or log unreadable: 409/500 asking for an explicit profile. It is never a silent fallback to the daemon defaults.
  • session/host.rs: SessionOverrides and open_session_with (open_session is a wrapper, so ACP and MCP are unchanged); a per-session pinned model.
  • main.rs: passes the user config path (none under --no-config), the daemon allow list, trust presets and whether --allow was a flag.
  • Docs: docs/mobile-control.md (Session profiles), CHANGELOG.md, README.md, docs/epics.md ([PLAN] serve: per-session profile on POST /sessions (+resume) — enabler personal fleet #740 leaves the parked table).
  • On resume the persona and model come from the effective profile, not from the header pinned at create; a profile-less resume is unchanged.

Testing

  • 14 real-binary e2e tests in crates/tole-cli/tests/serve_profile_e2e.rs, plus unit tests. They cover:
    • create with a profile (persona, model and room seen in the provider request and a fake uteke log)
    • two parallel profiles with no leak
    • unchanged behaviour without profile (list shape included)
    • unknown or malformed names (4xx, no file created)
    • memory_room refused
    • resume reconciliation, live-profile 409, removed profile, tampered or unreadable log, concurrent resumes
    • a profile allow list restricting a real write_file call, and the --allow pin
    • project-config profiles not selectable
  • Fail-first: each safety rule was broken in turn (11 mutants) and the tests failed for each.
    • unknown profile silently defaulting
    • memory_room accepted
    • --allow not pinning
    • room not applied
    • profile not recorded
    • live switch allowed
    • removed recorded profile falling back
    • request profile not winning
    • persona and model not applied
    • tampered or unreadable log read as no profile
    • list always carrying the key
  • cargo fmt --all is clean. Clippy with -D warnings is clean for the workspace (all features) and for --no-default-features with and without shell-tools. cargo check -p tole-core --no-default-features --tests and cargo check -p tole-cli --no-default-features pass. Tests pass in the default, --no-default-features and shell-tools-only profiles with TOLE_REQUIRE_BWRAP=1 --no-fail-fast.
  • A pre-PR independent review of the branch reported NO BLOCKER and ran the e2e, unit and no-default-features checks. Its notes are fixed in the last commit.
  • cora is not installed in the author's PATH and scripts/review-local.sh needs an LLM, so cora review --staged --no-llm was run before each commit with no issues. The CI Cora Review is the gate.

claude and others added 4 commits November 17, 2026 03:37
A request's optional profile selects a [profiles.<name>] table of the user config for one session: persona, allow list, memory room and model. The choice is fixed for the live session, wins over the recorded one on resume and is recorded as a fact/profile register. memory_room in a request is refused.
…ts (#740)

A recorded profile with a malformed name, or a log that cannot be read to look for one, is now a 409 or 500 asking for an explicit profile instead of resuming under the daemon defaults. GET /sessions adds the profile key only when set. Docs say child agents, the advisor and the router use the daemon model, and that a resume takes persona and model from the effective profile.
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

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.

2 participants