From 5cf9432092da40a2653c3d156ca5a4746e853827 Mon Sep 17 00:00:00 2001 From: main Date: Mon, 23 Mar 2026 16:13:37 -0400 Subject: Inject consult prompt prefix --- crates/phone-opus/src/mcp/protocol.rs | 14 ++++++++++++++ crates/phone-opus/src/mcp/service.rs | 24 +++++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) (limited to 'crates/phone-opus/src') diff --git a/crates/phone-opus/src/mcp/protocol.rs b/crates/phone-opus/src/mcp/protocol.rs index 5cd8313..b1ee587 100644 --- a/crates/phone-opus/src/mcp/protocol.rs +++ b/crates/phone-opus/src/mcp/protocol.rs @@ -12,6 +12,20 @@ pub(crate) const HOST_STATE_ENV: &str = "PHONE_OPUS_MCP_HOST_STATE"; pub(crate) const FORCE_ROLLOUT_ENV: &str = "PHONE_OPUS_MCP_TEST_FORCE_ROLLOUT_KEY"; pub(crate) const WORKER_CRASH_ONCE_ENV: &str = "PHONE_OPUS_MCP_TEST_WORKER_CRASH_ONCE_KEY"; pub(crate) const CLAUDE_BIN_ENV: &str = "PHONE_OPUS_CLAUDE_BIN"; +pub(crate) const CLAUDE_CONSULT_PREFIX: &str = r"You are being invoked in a read-only consultation mode by another model. You cannot edit files or make changes; your role is to inspect, reason, and advise. + +Take your time. Think deeply, check assumptions, and prefer a careful, high-signal analysis over a fast, shallow response. + +Your job is to produce a report for the calling model, not for an end user. Make it actionable. Itemize your findings and prioritize them by importance and urgency. Focus on concrete issues, risks, design flaws, behavioral regressions, missing validations, and better alternatives when relevant. + +When useful, distinguish clearly between: +- confirmed findings +- plausible risks or hypotheses +- open questions that would change the recommendation + +Prefer specific recommendations over vague commentary. If there are no meaningful problems, say so plainly. + +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,WebSearch"; diff --git a/crates/phone-opus/src/mcp/service.rs b/crates/phone-opus/src/mcp/service.rs index 378ce43..d42c0a0 100644 --- a/crates/phone-opus/src/mcp/service.rs +++ b/crates/phone-opus/src/mcp/service.rs @@ -14,7 +14,8 @@ use crate::mcp::output::{ ToolOutput, fallback_detailed_tool_output, split_presentation, tool_success, }; use crate::mcp::protocol::{ - CLAUDE_BIN_ENV, CLAUDE_EFFORT, CLAUDE_MODEL, CLAUDE_TOOLSET, EMPTY_MCP_CONFIG, + CLAUDE_BIN_ENV, CLAUDE_CONSULT_PREFIX, CLAUDE_EFFORT, CLAUDE_MODEL, CLAUDE_TOOLSET, + EMPTY_MCP_CONFIG, }; pub(crate) fn run_worker(generation: u64) -> Result<(), Box> { @@ -138,18 +139,28 @@ impl ConsultRequest { } #[derive(Debug, Clone)] -struct PromptText(String); +struct PromptText { + original: String, + rendered: String, +} impl PromptText { fn parse(raw: String) -> Result { if raw.trim().is_empty() { return Err(ConsultRequestError::EmptyPrompt); } - Ok(Self(raw)) + Ok(Self { + rendered: format!("{CLAUDE_CONSULT_PREFIX}\n\n{raw}"), + original: raw, + }) } fn as_str(&self) -> &str { - self.0.as_str() + self.original.as_str() + } + + fn rendered(&self) -> &str { + self.rendered.as_str() } } @@ -364,7 +375,7 @@ fn invoke_claude(request: &ConsultRequest) -> Result