Repository navigation
Description
Context
src-tauri/crates/mas-ai/src/tools.rs:7-15 (block_on_async) wraps the future in tokio::time::timeout(Duration::from_secs(60), fut) and panics with .expect("AI tool execution timed out after 60s") on timeout. Audit finding F7 in docs/audits/ai.md.
Problem
The runtime this runs in is the SDK permission/tool handler thread — a panic there unwinds the Rust stack and kills the entire Tauri command future, including the pending await events.recv().await in service.rs:368 and the spawned emitter task in commands/ai.rs:22-40. The user sees a "rust panicked" in the dev tools console, the AI panel stream freezes, and the conversation is unrecoverable until the process restarts. A SELECT * FROM huge_table issued via run_select_query over a slow connection will hit this 60s cliff and panic. The agent emits no ToolComplete event (panic happens before ToolResultObject::text(...) returns), so the frontend sees a stuck spinner with no error.
Files
- src-tauri/crates/mas-ai/src/tools.rs:6-15 (block_on_async)
- src-tauri/crates/mas-ai/src/service.rs:295-345 (per-tool permission handler — uses block_in_place, not directly affected but related)
- src-tauri/src/commands/ai.rs:22-40 (emitter task joined via
_ = emitter.await)
Repro
Dispatch a tool call that sleeps for 70s in its handler. Observe a Rust panic in the dev console, the AI panel hangs in a "running" state, no ToolComplete event fires.
Expected
A 70s tool returns a ToolComplete { success: false, result: "Tool execution timed out after 60s" } event. The frontend ToolCallBlock shows the error icon with the timeout message in result. No Rust panic.
Proposed fix
Scope S. Replace .expect(...) with match/ok_or_else: convert Timeout into Err("Tool execution timed out after 60s".to_string()) and let ToolResultObject::error(...) propagate it to the SDK normally. The event loop will see ToolComplete { success: false, result: "Tool execution timed out..." } and the frontend gets a clean error.
Acceptance
Simulate a tool handler that sleeps 70s; tool_start and tool_complete(success=false, ...) events both fire; no process panic; AIChatPanel ToolCallBlock shows the error icon with the timeout message.
Needs human verify
yes (panic vs graceful behavior depends on tokio runtime config)
Activity
EVWorth commentedon Sep 12, 2026
Closing as obsolete rather than fixed: this describes the implementation that ADR-011 replaces.
The AI feature is being rebuilt around a decision made in #673 — SQLPilot does not call a model. It exposes the database, under its own policy, to whatever harness the user already runs and pays for. The
mas-aicrate, its Copilot SDK session, its system prompt and its tool guards are all going.What that does to this issue specifically: no tool handler of ours panics a worker any more, because the handler is an MCP tool implementation rather than a callback inside an SDK's loop. The
block_on_async.expect()goes with the crate.The design is in docs/design/AI_INTEGRATION.md and ADR-011. If any part of this issue survives the redesign in a form I have missed, reopen it — I would rather re-argue it than lose it.