Skip to content

feat(core): advisor seam, advisor_max_uses and doctor line (#587 part 1) - #653

Merged
ajianaz merged 1 commit into
developfrom
feat/advisor-core
Nov 13, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/advisor-core

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 1 of #587 (the advisor tier): the core seam in tole-core, the profiles.<name>.advisor_max_uses key with its validation, and the tole doctor line. No run consults an advisor yet; consult_advisor in runs comes in part 2.

Depends on: nothing unmerged; based on the latest develop.

Why

A cheaper executor that can consult a stronger model on hard decisions does better at lower cost, but Anthropic's server-side advisor tool cannot be used through tole's OpenAI-compatible provider. Design A10 puts the advisor on the host side. This PR holds the parts that decide what the advisor sees, what the host reads back and what it costs, with no I/O, so part 2 only has to wire them in.

Changes

  • crates/tole-core/src/advisor.rs (new): no I/O, no provider call, builds with --no-default-features.
    • request(contract, entries, question, secrets) builds the advisor call:
      • the fixed SYSTEM_PROMPT (the executor cannot change it);
      • one user message with the task contract (4,000 characters), the last 12 transcript entries (each at most 1,500, together at most 12,000, newest kept first) and the question (2,000);
      • every part is redacted with the process secrets, then neutralized (fence markers, control characters), then capped, and fenced as data.
    • parse_reply reads only a verdict word (plan, correction or stop, before a colon) and capped, redacted text (2,000 characters).
      • Nothing else is parsed, so an advisor cannot name a tool, grant or budget for the host to act on.
      • A reply without a verdict word is a plan, never a stop.
      • Verdict::fenced returns it to the executor as {verdict, advice} between advisory-data markers.
    • Uses caps consultations per run. Budget is the run's token budget, shared by the run's meter and the advisor: admit before a call, charge after, never below zero. Advisor tokens come out of the run's budget.
    • usage_value tags a consultation's usage "role": "advisor".
  • config.rs: profiles.<name>.advisor_max_uses (default 3, 1 to 20).
    • It is refused without models.advisor, naming the remedy.
    • A blank models.advisor is refused.
    • Like every profile key, it lives in the user config only.
  • profile.rs: Profile::advisor and advisor_max_uses, plus advisor_doctor_lines: profile names and caps only, never the model.
  • tole doctor prints that line.
  • Docs: CHANGELOG [Unreleased], design A10 "as implemented, part 1" (including your part 2 constraints of 2026-11-13), a threat-model row, the README profile example and docs/epics.md.
  • Dependencies: no change.

Testing

  • TDD:
    • core: the 7 tests went red against stubs (7 of 7 failed), then green;
    • profile tests: red (the new fields did not exist), then green.
  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace
  • cargo test -p tole-core --no-default-features
  • No-mcp CI commands:
    • cargo check -p tole-cli --no-default-features
    • cargo clippy -p tole-cli --no-default-features --features shell-tools -- -D warnings
    • cargo test -p tole-cli --no-default-features
  • cora review --no-llm --staged: no issues.
  • New tests:
    • advisor_tests.rs: 7 tests;
    • profile.rs: 2 tests;
    • doctor_ecosystem.rs: 1 test on the real binary.
  • Mutation breaks, each restored afterwards; the tests caught all 18:
    • an unlabelled reply becomes a stop;
    • an unknown label becomes a stop;
    • fence markers pass;
    • control characters pass;
    • no redaction;
    • capping before redacting;
    • the window takes all entries;
    • the window cap is ignored;
    • the entry cap is ignored;
    • the question is not cleaned;
    • the use cap is off by one;
    • the budget admits over;
    • the usage role is wrong;
    • advisor_max_uses = 0 is allowed;
    • advisor_max_uses without an advisor is allowed;
    • a blank advisor is allowed;
    • doctor shows the model;
    • the doctor line is not printed.
  • Two of these (control characters, cap before redact) survived on the first run. I strengthened the test, and both are caught now.

tole_core::advisor builds an advisor call from the host's view of a run
(fixed instructions, then the task contract, the last 12 transcript
entries and the question, each redacted, neutralized and capped before
it is fenced as data), parses only a verdict (plan, correction, stop)
and capped text from the reply, caps consultations per run and shares
the run's token budget with the advisor. profiles.<name>.advisor_max_uses
(default 3, 1 to 20) needs models.advisor; tole doctor names the
profiles that declare one, never the model. No run consults an advisor
yet.
@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 1fda8dc into develop Nov 13, 2026
19 checks passed
@ajianaz
ajianaz deleted the feat/advisor-core branch November 20, 2026 08:35
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