wai-quantum-cli: a job on a provider is an MCP task #609
Loading…
Reference in a new issue
No description provided.
Delete branch "wai/quantum-cli-provider-tasks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A client on MCP 2025-11-25 can now run a job on one of the person's own providers as a task, the protocol's own way to wait. Until now an agent ran
run_on_providerand then had to remember to come back withget_provider_job. The job service gets the same feature for its own runs in a separate change. This PR covers the local server's provider jobs, which are where the waits are long: a device's queue can take hours or days.What changes
initializedeclarestasks(list,cancel,requests.tools.call) from 2025-11-25 on.run_on_providerdeclaresexecution.taskSupport: "optional".tools/callwithtaskrecords the job, sends it, and answers as soon as the provider has taken it. ThetaskIdis the job'spj-…handle.run --no-wait, an earlier session, another agent.tasks/getasks the provider once. If the question fails, the task is returned as recorded and its message says why.tasks/listreads the records and asks no provider. It is listed in full here because the records are one person's own; the service leaveslistout for that reason.tasks/cancelcancels at the provider, and refuses a task that has ended.ttlisnull, because records are kept.tasks/resultwaits without holding the server. The local server is stdio and handles one message at a time, so atasks/resultthat blocked for a device's queue would freeze it, including thetasks/cancelmeant for that job.tasks/cancelhere wakes the waits at once. A request the client cancels (notifications/cancelled) is never answered.Tests
an_agent_runs_on_a_provider_as_a_task_and_the_server_answers_while_it_waitsruns over stdio against this binary's reference provider served over HTTP. It covers each of these:pingandtasks/getare answered;tasks/cancelstill ends it within 3 s;tasks/list, and the refusals: a tool that isn't a run, a priced run without confirmation (nothing recorded), a bad handle, a cursor;The unit tests cover the job-to-task mapping and the wait's wake and cancel. All three are added to the CLI workflow's by-name list. Each test cleans up the processes it started, even when it fails.
Ran on the x86_64 Linux build host:
cargo test --locked --release;-D warningswith default features, with none, withserviceonly and withprovidersonly;wasm32-wasip2build without default features;Each mutation was applied on its own, and the end-to-end test failed for all 9:
tasks/resultanswered in the read loop rather than in its own thread;tasks/cancelnot waking the waits;notifications/cancelledignored;tasksdeclared to every protocol version;tasks/listempty;confirm_costmaking a task;ttl;_metanot naming its task.The in-process lock that keeps two questions from both sealing one job has no test; it is a race the test cannot force.
🤖 Generated with Claude Code