diff options
| author | main <main@swarm.moe> | 2026-03-31 13:07:12 -0400 |
|---|---|---|
| committer | main <main@swarm.moe> | 2026-03-31 13:07:12 -0400 |
| commit | 2160224b7ef21e3319a93d057165712aabe8cbe2 (patch) | |
| tree | adad1f3f29eee071dae06766e057d851bf26e39c /crates/phone-opus/src/mcp | |
| parent | 2bb470f0b28b75863809f127b7f12222db07496c (diff) | |
| download | phone_opus-2160224b7ef21e3319a93d057165712aabe8cbe2.zip | |
Exterminate inert consult slop
Diffstat (limited to 'crates/phone-opus/src/mcp')
| -rw-r--r-- | crates/phone-opus/src/mcp/protocol.rs | 41 | ||||
| -rw-r--r-- | crates/phone-opus/src/mcp/service.rs | 12 | ||||
| -rw-r--r-- | crates/phone-opus/src/mcp/telemetry.rs | 20 |
3 files changed, 52 insertions, 21 deletions
diff --git a/crates/phone-opus/src/mcp/protocol.rs b/crates/phone-opus/src/mcp/protocol.rs index 9d3ec1a..79c2169 100644 --- a/crates/phone-opus/src/mcp/protocol.rs +++ b/crates/phone-opus/src/mcp/protocol.rs @@ -28,9 +28,48 @@ Prefer specific recommendations over vague commentary. If there are no meaningfu The real prompt follows."; pub(crate) const CLAUDE_EFFORT: &str = "max"; pub(crate) const CLAUDE_MODEL: &str = "claude-opus-4-6"; -pub(crate) const CLAUDE_TOOLSET: &str = "Bash,Read,Grep,Glob,LS,WebFetch"; pub(crate) const EMPTY_MCP_CONFIG: &str = "{\"mcpServers\":{}}"; +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub(crate) enum ClaudeTool { + Bash, + Read, + Grep, + Glob, + Ls, + WebFetch, +} + +impl ClaudeTool { + const fn cli_name(self) -> &'static str { + match self { + Self::Bash => "Bash", + Self::Read => "Read", + Self::Grep => "Grep", + Self::Glob => "Glob", + Self::Ls => "LS", + Self::WebFetch => "WebFetch", + } + } +} + +pub(crate) const CLAUDE_TOOLSET: &[ClaudeTool] = &[ + ClaudeTool::Bash, + ClaudeTool::Read, + ClaudeTool::Grep, + ClaudeTool::Glob, + ClaudeTool::Ls, + ClaudeTool::WebFetch, +]; + +pub(crate) fn render_claude_toolset(toolset: &[ClaudeTool]) -> String { + toolset + .iter() + .map(|tool| tool.cli_name()) + .collect::<Vec<_>>() + .join(",") +} + #[derive(Clone, Debug, Deserialize, Serialize)] pub(crate) struct HostStateSeed { pub(crate) session_kernel: HostSessionKernelSnapshot, diff --git a/crates/phone-opus/src/mcp/service.rs b/crates/phone-opus/src/mcp/service.rs index 051ff83..afb811e 100644 --- a/crates/phone-opus/src/mcp/service.rs +++ b/crates/phone-opus/src/mcp/service.rs @@ -24,7 +24,7 @@ use crate::mcp::output::{ }; use crate::mcp::protocol::{ CLAUDE_BIN_ENV, CLAUDE_CONSULT_PREFIX, CLAUDE_EFFORT, CLAUDE_MODEL, CLAUDE_TOOLSET, - EMPTY_MCP_CONFIG, + EMPTY_MCP_CONFIG, render_claude_toolset, }; pub(crate) fn run_worker(generation: u64) -> Result<(), Box<dyn std::error::Error>> { @@ -117,7 +117,6 @@ impl WorkerService { struct ConsultArgs { prompt: String, cwd: Option<String>, - fresh_context: Option<bool>, } #[derive(Debug, Deserialize)] @@ -146,7 +145,6 @@ struct ConsultRequest { prompt: PromptText, cwd: WorkingDirectory, context_key: ConsultContextKey, - fresh_context: bool, session_plan: ConsultSessionPlan, } @@ -155,13 +153,11 @@ impl ConsultRequest { let prompt = PromptText::parse(args.prompt)?; let cwd = WorkingDirectory::resolve(args.cwd)?; let context_key = ConsultContextKey::from_cwd(&cwd); - let fresh_context = args.fresh_context.unwrap_or(false); let session_plan = ConsultSessionPlan::fresh(); Ok(Self { prompt, cwd, context_key, - fresh_context, session_plan, }) } @@ -214,7 +210,6 @@ impl ConsultRequest { BackgroundConsultRequest { prompt: self.prompt.as_str().to_owned(), cwd: self.cwd.display(), - fresh_context: self.fresh_context, } } } @@ -464,7 +459,6 @@ impl ConsultSessionPlan { struct BackgroundConsultRequest { prompt: String, cwd: String, - fresh_context: bool, } impl BackgroundConsultRequest { @@ -472,7 +466,6 @@ impl BackgroundConsultRequest { ConsultRequest::parse(ConsultArgs { prompt: self.prompt, cwd: Some(self.cwd), - fresh_context: Some(self.fresh_context), }) } } @@ -659,7 +652,6 @@ impl BackgroundConsultJobRecord { "finished_unix_ms": self.finished_unix_ms, "runner_pid": self.runner_pid, "cwd": self.request.cwd, - "fresh_context": self.request.fresh_context, "prompt_prefix_injected": self.prompt_prefix_injected, }) } @@ -1647,7 +1639,7 @@ fn invoke_claude(request: &ConsultRequest) -> Result<ConsultResponse, ConsultInv .arg("--effort") .arg(CLAUDE_EFFORT) .arg("--tools") - .arg(CLAUDE_TOOLSET) + .arg(render_claude_toolset(CLAUDE_TOOLSET)) .arg("--dangerously-skip-permissions") .stdout(Stdio::piped()) .stderr(Stdio::piped()); diff --git a/crates/phone-opus/src/mcp/telemetry.rs b/crates/phone-opus/src/mcp/telemetry.rs index 8df0009..5b91d78 100644 --- a/crates/phone-opus/src/mcp/telemetry.rs +++ b/crates/phone-opus/src/mcp/telemetry.rs @@ -84,11 +84,7 @@ impl ServerTelemetry { self.totals.success_count += 1; let entry = self.methods.entry(operation.to_owned()).or_default(); entry.success_count += 1; - entry.total_latency_ms = entry - .total_latency_ms - .saturating_add(u128::from(latency_ms)); - entry.max_latency_ms = entry.max_latency_ms.max(latency_ms); - entry.last_latency_ms = Some(latency_ms); + record_latency_sample(entry, latency_ms); entry.last_error = None; } @@ -123,11 +119,7 @@ impl ServerTelemetry { } else { entry.response_error_count += 1; } - entry.total_latency_ms = entry - .total_latency_ms - .saturating_add(u128::from(latency_ms)); - entry.max_latency_ms = entry.max_latency_ms.max(latency_ms); - entry.last_latency_ms = Some(latency_ms); + record_latency_sample(entry, latency_ms); entry.last_error = Some(fault.message().to_owned()); } @@ -211,6 +203,14 @@ impl ServerTelemetry { } } +fn record_latency_sample(stats: &mut MethodStats, latency_ms: u64) { + stats.total_latency_ms = stats + .total_latency_ms + .saturating_add(u128::from(latency_ms)); + stats.max_latency_ms = stats.max_latency_ms.max(latency_ms); + stats.last_latency_ms = Some(latency_ms); +} + fn average_latency_ms(stats: &MethodStats) -> u64 { if stats.request_count == 0 { return 0; |