Skip to content

Agent panel Cancel doesn't stop the agent's running SQL #868

Closed

Description

@EVWorth

Severity: P2.

The agent panel's Cancel (cancel_agent_turn in src-tauri/src/commands/agents.rs) calls AgentSessions::cancel, which asks the harness to stop the turn. It does not send KILL QUERY for a statement the agent already has running on the server.

Until PR #866, the editor's Cancel stopped every statement on the connection, the agent's included, so a runaway agent query could be stopped that way. Since #866 the editor's Cancel only stops the run the user is looking at: a tab's own session, or the shared pool for a session-less run. That is correct for the editor. It means nothing reachable from the UI now stops SQL running on the Agent lane. That SQL is still bounded by the executor's query timeout, and its pool closes when the agent session ends.

Fix

When an agent turn is cancelled, also cancel its in-flight statements. Call QueryExecutor::cancel for each connection the agent session has used, scoped to that agent's Route::Agent lane (add a CancelScope::Agent(id)). Add a live test in src-tauri/crates/mas-core/tests/connection_lanes.rs next to cancel_still_stops_what_the_agent_is_running.

Found while scoping cancels per tab (#842).

Activity

  1. added a commit that references this issue on Oct 24, 2026
    9221d35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions