From c3ad44cf3ec3bcd080f62c19d915ac1749576302 Mon Sep 17 00:00:00 2001 From: main Date: Mon, 23 Mar 2026 16:28:52 -0400 Subject: Add optional background consult jobs --- crates/phone-opus/src/mcp/catalog.rs | 38 +++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'crates/phone-opus/src/mcp/catalog.rs') diff --git a/crates/phone-opus/src/mcp/catalog.rs b/crates/phone-opus/src/mcp/catalog.rs index 4c71e83..839c477 100644 --- a/crates/phone-opus/src/mcp/catalog.rs +++ b/crates/phone-opus/src/mcp/catalog.rs @@ -41,10 +41,22 @@ impl ToolSpec { const TOOL_SPECS: &[ToolSpec] = &[ ToolSpec { name: "consult", - description: "Run a blocking consult against the system Claude Code install using a read-only built-in toolset, optionally resume a prior Claude session by session_id, and return the response.", + description: "Run a consult against the system Claude Code install using a read-only built-in toolset, optionally resume a prior Claude session by session_id, optionally queue the consult in the background, and return the response or job handle.", dispatch: DispatchTarget::Worker, replay: ReplayContract::NeverReplay, }, + ToolSpec { + name: "consult_job", + description: "Read the status of one background consult job by job_id. When the job has finished, the final Claude response or failure is included.", + dispatch: DispatchTarget::Host, + replay: ReplayContract::Convergent, + }, + ToolSpec { + name: "consult_jobs", + description: "List recent background consult jobs. Defaults to render=porcelain; use render=json for structured output.", + dispatch: DispatchTarget::Host, + replay: ReplayContract::Convergent, + }, ToolSpec { name: "health_snapshot", description: "Read host lifecycle, worker generation, rollout state, and latest fault. Defaults to render=porcelain; use render=json for structured output.", @@ -98,10 +110,34 @@ fn tool_schema(name: &str) -> Value { "session_id": { "type": "string", "description": "Optional Claude session handle returned by a previous consult call. When set, phone_opus resumes that conversation instead of starting a fresh one." + }, + "background": { + "type": "boolean", + "description": "When true, queue the consult as a background job and return immediately with a job handle. The default is false, which keeps consult synchronous." } }, "required": ["prompt"] })), + "consult_job" => with_common_presentation(json!({ + "type": "object", + "properties": { + "job_id": { + "type": "string", + "description": "Background consult job handle returned by consult with background=true." + } + }, + "required": ["job_id"] + })), + "consult_jobs" => with_common_presentation(json!({ + "type": "object", + "properties": { + "limit": { + "type": "integer", + "minimum": 1, + "description": "Maximum number of recent background jobs to return. Defaults to 10." + } + } + })), "health_snapshot" | "telemetry_snapshot" => with_common_presentation(json!({ "type": "object", "properties": {} -- cgit v1.2.3