//! Manual probe for the subscription-auth seam. Unit tests cover header //! selection and the system preamble, but nothing offline can prove Anthropic //! actually accepts a setup token — this does, against the real API. //! //! It builds the same request `cm_api::evaluator::complete_direct` builds, so //! its `INPUT_TOKENS` line is the honest cost of one phase verdict: //! //! ANTHROPIC_OAUTH_TOKEN=sk-ant-oat01-… cargo run -p cm-llm --example oauth_probe //! //! Measured 2026-08-01: **114** input tokens here, against **17,772** for the //! same verdict routed through a ZeroClaw judge agent. use cm_llm::{ChatMessage, ChatRequest, ChatRole, ContentPart, LlmEvent, LlmProvider}; use futures::StreamExt as _; #[tokio::main] async fn main() { let token = std::env::var("ANTHROPIC_OAUTH_TOKEN").expect("ANTHROPIC_OAUTH_TOKEN"); let p = cm_llm::AnthropicProvider::new(token); let req = ChatRequest { system: "You judge whether a phase of automated work is complete.\n\nRespond with STRICT JSON ONLY: {\"met\": true|false, \"reason\": \"one sentence\"}".into(), model: "claude-haiku-4-5-20251001".into(), messages: vec![ChatMessage { role: ChatRole::User, parts: vec![ContentPart::text( "COMPLETION CONDITION:\nThe research output names at least two concrete tradeoffs.\n\nEVIDENCE:\nThe agent produced: (1) fail-closed blocks progress on evaluator outage; (2) fail-open can falsely approve. Both named with consequences.", )], }], tools: vec![], max_tokens: 512, web_search: false, }; let mut text = String::new(); let mut stream = p.stream(req).await.expect("stream"); while let Some(ev) = stream.next().await { match ev { Ok(LlmEvent::TextDelta(t)) => text.push_str(&t), Ok(LlmEvent::Usage { input_tokens, .. }) => eprintln!("INPUT_TOKENS={input_tokens}"), Ok(_) => {} Err(e) => { eprintln!("ERR: {e}"); std::process::exit(1); } } } println!("REPLY: {text}"); }