Skip to content

fix: cancel can't reach an agent's staged writes or schema reads #894

Closed

Description

@EVWorth

Cancel (the panel's Stop, CancelScope::All, and the new CancelScope::Agent from #868) only reaches statements the executor tracks as in flight. Two kinds of agent work aren't tracked:

  • Staged writes. CoreStagedWrite::begin (src-tauri/crates/mas-core/src/query/staged.rs, around line 113) runs .execute(&mut connection) directly. A long DELETE staged for approval keeps running until it hits its timeout, even after Stop.
  • Schema reads. The schema inspector never goes through the executor, so a slow information_schema read for an agent can't be cancelled.

run, run_ddl and explain are covered.

Reproduce

Against the test server, have an agent stage a write that takes a long time, for example DELETE … WHERE SLEEP(1) = 0 over enough rows, then press Stop. SHOW PROCESSLIST still shows the statement.

Fix

Register the staged write's thread id with the executor's in-flight table under the agent's route, just as execute_routed does, and remove it when the stage finishes. Do the same for inspector queries issued on an agent route. Extend connection_lanes.rs's an_agent_cancel_stops_only_that_agents_statements with a staged write. Update the limit noted in docs/design/AI_INTEGRATION.md §6.

Found while fixing #868.

Activity

  1. added
    bug
    on Oct 24, 2026
  2. added a commit that references this issue on Oct 25, 2026
    7d36c53
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions