Skip to content

feat(cli): consult_advisor host tool, tap and usage records (#587 part 2a) - #654

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

ajianaz merged 1 commit into
developfrom
feat/advisor-tool

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 2a of #587: tole_cli::advisor_host, the host side of consult_advisor. No run registers the tool yet; part 2b (#655, stacked on this PR) wires it into missions, delegated children and cron runs.

Depends on: #653 (part 1, tole_core::advisor), which is merged. Based on the latest develop.

Why

Part 1 decided what the advisor sees, what is read back and what it costs. This module makes the call under your constraints of 2026-11-13:

  • the window comes from an in-memory view, never a file;
  • the run's budget is shared, so there is never an uncounted advisor;
  • the call has no tools and no streaming;
  • the reply is read only through parse_reply;
  • usage is recorded with role: advisor.

The split keeps both PRs under ~900 lines.

Changes

  • ConsultAdvisor (ReadOnly, question input):
    • builds the call with tole_core::advisor::request from the task contract, the question and the window: redacted, neutralized and capped;
    • refuses, before any call and without spending a use, a consultation the shared Budget cannot fit (the request plus 600 tokens for the reply); then refuses past advisor_max_uses;
    • makes one call through a Factory. The production factory is the advisor model on the run's provider connection, with the process secrets, no tools, no streaming and no fallback chain (a fallback would be another model);
    • charges and queues what the call spent, even when it fails;
    • returns only {advisor: <fenced verdict>, verdict, use, of, tokens}; a provider error is reported redacted and capped;
    • answers an advisor's own tool call with an error, and nothing runs.
  • Tap: wraps the run's provider. On each step it keeps the last 12 entries of the transcript the turn loop sends, in memory. With charge, it charges each step's usage to the shared Budget; a face whose own meter charges the budget passes false.
  • record_usage: writes the queued advisor usage to the session as usage records tagged "role": "advisor".
  • CHANGELOG [Unreleased]. The design note, threat-model row, README and epics update ship with feat(cli): consult_advisor in missions, delegated children and cron runs (#587 part 2b) #655, which makes the tool reachable.

Testing

  • TDD: the 6 unit tests went red against stubs (6 of 6 failed), 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
  • The commands above ran on the combined tree (this PR plus feat(cli): consult_advisor in missions, delegated children and cron runs (#587 part 2b) #655).
  • cora review --no-llm --staged: no issues.
  • The 6 unit tests in advisor_host_tests.rs, with a recording fake provider, cover:
    • the tap's window and charging (and not charging twice);
    • a consultation returns only the fenced verdict, is redacted and is counted and queued;
    • the use cap and a budget that cannot fit refuse with no call, and the use is not spent;
    • a provider error or an empty reply is survivable and still counted;
    • a hostile reply or an advisor tool call makes the host do nothing;
    • queued usage becomes session usage records.
  • Mutation breaks, each restored afterwards; the tests caught all 11 for this module:
    • the tap keeps no window;
    • the tap charges when told not to;
    • no budget admission;
    • a use is spent before admission;
    • no use cap;
    • what was spent is not charged;
    • usage is not queued;
    • the raw reply is returned;
    • an advisor tool call is accepted;
    • the error is not redacted;
    • usage is never recorded.

…t 2a)

tole_cli::advisor_host: ConsultAdvisor (ReadOnly) makes one advisor call
with no tools, no streaming and no fallback chain, built from the task
contract, the question and an in-memory window of the run's transcript
kept by Tap, and returns only the fenced verdict. A consultation the
run's shared Budget cannot fit, or past advisor_max_uses, is refused
before any call; what a call spent is charged and queued even when it
fails, and record_usage writes it to the session tagged role advisor.
No run registers the tool 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 7086c2e into develop Nov 13, 2026
19 checks passed
@ajianaz
ajianaz deleted the feat/advisor-tool 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