fabro/lib/components/fabro-agent/tests/it/guardrails.rs
Bryan Helmkamp 4ce57f8aae
refactor: simplify profile builder and drop dead tool plumbing
Follow-up cleanup on the profile-builder refactor.

AgentProfileBuilder::build now borrows instead of consuming, removing the
builder.clone().build() dance at all seven call sites. Deletes
with_command_timeouts, which had no caller but its own test, and the
with_summarizer constructors on all three profiles, whose only remaining
caller was each profile's own new().

Replaces the fifth copy of the profile-kind match (guardrails.rs) with the
builder, and swaps the parity matrix's hand-maintained provider list for
Catalog::effective_agent_profile so a new catalog provider cannot silently
skip the matrix. Collapses web_search_provider_test! into a secrets = arm
on provider_test! and uses EnvVars::BRAVE_SEARCH_API_KEY over a literal.

Drops the Brave key from the Ask Fabro session: AskFabroToolAccessPolicy
denies web_search, and both tools() and the prompt are filtered through
that policy, so the vault read only registered an uncallable tool.

Makes NativeToolOptions::for_profile match exhaustively so a new profile
kind must state its timeout, restores Anthropic's borrowed prompt sections
and Gemini's static prompt (placeholder substitution rather than format!
over 110 lines with doubled braces), and introduces WEB_SEARCH_TOOL_NAME
for the registry lookups that keep tool availability and prompt guidance
in sync.

Updates the product docs, which still described web_search as always
registered and as erroring at call time when unconfigured.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-24 17:32:33 -04:00

36 lines
1.2 KiB
Rust

use std::sync::Arc;
use fabro_agent::{AgentProfile, AgentProfileBuilder};
use fabro_model::Catalog;
#[test]
fn profile_context_window_matches_catalog_for_default_models() {
let catalog = Arc::new(Catalog::from_builtin().unwrap());
for provider in catalog.providers() {
let catalog_info = catalog
.default_for_provider(&provider.id)
.cloned()
.unwrap_or_else(|| panic!("no default model for {:?} in catalog", provider.id));
let model = &catalog_info.id;
let context_window = usize::try_from(catalog_info.context_window())
.expect("catalog context window should be non-negative and fit in usize");
let profile: Box<dyn AgentProfile> = AgentProfileBuilder::new(
provider.agent_profile,
provider.id.clone(),
model.as_str(),
Arc::clone(&catalog),
)
.build();
assert_eq!(
profile.context_window_size(),
context_window,
"context_window_size mismatch for {:?} model '{}': profile={} catalog={}",
provider.id,
model,
profile.context_window_size(),
context_window
);
}
}