[GH-ISSUE #97] Support MCP Tasks for long-running analysis operations #63

Closed
opened 2026-10-15 18:20:40 +00:00 by bsakaguchi · 3 comments
Owner

Originally created by @morluto on GitHub (Jul 13, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/97

Summary

Add a provider-neutral asynchronous job model and expose eligible long-running REA operations through capability-negotiated MCP Tasks. Preserve synchronous tool calls for clients that do not support Tasks.

MCP Tasks are experimental. REA's core execution model must not depend directly on unstable SDK APIs; the MCP Tasks adapter should sit over an internal operation abstraction with explicit ownership, status, cancellation, retention, and result identity.

Current state in REA 1.3.0

  • Hopper loading, artifact inventory, process capture, cross-version investigation, and reconstruction verification remain synchronous calls.
  • REA has strong process/session ownership and persistent snapshot/workspace primitives, but no general background-job abstraction.
  • There is no tasks/get, tasks/result, tasks/list, tasks/cancel, task retention store, or related-task metadata.
  • Guided prompts and completion are shipped, but they do not execute or retain work.
  • Process permission elicitation is tracked separately in #96.
  • Ordinary progress and cancellation are tracked in #98.

User problem

Expensive work can exceed a comfortable tool-call lifetime. Agents cannot:

  • start work and continue other reasoning;
  • recover a result after a client reconnect;
  • poll durable phase status;
  • cancel through a stateful protocol;
  • distinguish waiting for user input from active computation;
  • retrieve completed evidence without re-running analysis.

Proposed architecture

1. Internal operation model

Introduce an SDK-independent operation state machine with queued, working, input_required, completed, failed, and cancelled states.

Each operation should own:

  • cryptographically strong ID;
  • operation kind and normalized request identity;
  • originating session/authorization context;
  • created/updated timestamps;
  • bounded TTL;
  • status and safe status message;
  • progress state;
  • cancellation signal;
  • cleanup state;
  • final typed tool result or typed failure;
  • evidence IDs produced during execution.

2. MCP Tasks adapter

When the client advertises the required Tasks capability:

  • accept a task-augmented tools/call;
  • return CreateTaskResult promptly;
  • implement tasks/get, tasks/result, tasks/list, and tasks/cancel;
  • attach io.modelcontextprotocol/related-task metadata to associated progress and elicitation;
  • bind task access to the originating connection or authorization context;
  • make tasks/result return exactly the underlying tool result.

3. Compatibility path

For clients without Tasks:

  • retain current synchronous behavior;
  • use ordinary progress and cancellation from #98;
  • never advertise task-backed behavior that the client cannot consume.

4. Initial eligible operations

Start with operations whose runtime or output justifies task execution:

  1. binary/Hopper open and analysis;
  2. exhaustive artifact inventory;
  3. bounded process capture;
  4. persistent cross-version investigation;
  5. reconstruction verification;
  6. large batch decompilation or comparison.

Small navigation and read-only metadata calls should remain synchronous.

Security and lifecycle requirements

  • Task IDs must be unguessable and scoped to the originating context.
  • tasks/list must not expose work across clients.
  • Cancellation must stop owned work and run verified cleanup.
  • Expired results must be deleted promptly.
  • Task results must retain Evidence v2 identity and limitations.
  • input_required must not be used to bypass permission policy.
  • An MCP disconnect may retain a task only when its authorization context remains safely recoverable; otherwise cancel it.
  • Concurrency and retained-byte limits must be enforced per client.

Acceptance criteria

  • An internal operation abstraction exists independently of MCP SDK Tasks types.
  • Hopper analysis, artifact inventory, process capture, cross-version investigation, and reconstruction verification can run through it.
  • Capability-negotiated MCP Tasks support tasks/get, tasks/result, tasks/list, and tasks/cancel.
  • tasks/result is contract-equivalent to the corresponding synchronous tool result.
  • Status messages identify useful phases without exposing sensitive provider diagnostics.
  • Progress tokens continue across the task lifetime.
  • input_required can associate a permission elicitation from #96 with the task.
  • Cancellation propagates through providers and verifies cleanup.
  • Results have documented TTL, byte, and concurrency limits.
  • Task access is bound to the correct connection/authorization context.
  • Synchronous fallback remains fully supported.
  • Tests cover success, typed failure, cancellation, cancellation races, expiry, input_required, disconnect, result retrieval, unauthorized lookup, list isolation, and unsupported-client fallback.
  • Documentation marks the MCP Tasks surface experimental and identifies the supported protocol/SDK versions.

Non-goals

  • Making every tiny REA tool asynchronous.
  • Treating Tasks as permanent evidence storage.
  • Allowing task execution to expand filesystem, executable, or network policy.
  • Depending on deprecated MCP sampling, roots, or logging.

Dependencies

  • #98 for common progress/cancellation primitives.
  • #96 for scoped permission elicitation.
  • #99 for addressable retained evidence after task completion.

July 2026 SDK and Tasks extension update

REA currently pins the split MCP SDK packages at 2.0.0-beta.4. Investigation of beta.3 and beta.4 found that their exported task schemas describe the experimental 2025-11-25 task design, but the SDK does not provide the former high-level task manager/runtime. Meanwhile, current MCP Tasks work has moved to the Extensions Track and uses a different evolving contract, including different operation and result shapes.

The internal operation model in this issue remains required and should proceed independently of MCP wire types. The MCP adapter described above is now a historical target, not an implementation contract.

Before implementing the public adapter:

  • select and document one exact Tasks extension revision and compatible SDK version;
  • reconcile tasks/list and tasks/result assumptions with the selected extension;
  • reconcile task capability negotiation, result discrimination, update/input flow, cancellation, and related-task metadata with that revision;
  • keep all extension-specific schemas and lifecycle translation in the MCP adapter;
  • retain synchronous fallback and ordinary progress/cancellation from #98;
  • add conformance tests proving the selected wire contract rather than relying only on exported TypeScript types.

Acceptance criteria referring to specific task methods or metadata should be evaluated against the selected extension revision before implementation. No task capability should be advertised until REA implements and tests the complete selected contract.

Originally created by @morluto on GitHub (Jul 13, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/97 ## Summary Add a provider-neutral asynchronous job model and expose eligible long-running REA operations through capability-negotiated MCP Tasks. Preserve synchronous tool calls for clients that do not support Tasks. MCP Tasks are experimental. REA's core execution model must not depend directly on unstable SDK APIs; the MCP Tasks adapter should sit over an internal operation abstraction with explicit ownership, status, cancellation, retention, and result identity. ## Current state in REA 1.3.0 - Hopper loading, artifact inventory, process capture, cross-version investigation, and reconstruction verification remain synchronous calls. - REA has strong process/session ownership and persistent snapshot/workspace primitives, but no general background-job abstraction. - There is no tasks/get, tasks/result, tasks/list, tasks/cancel, task retention store, or related-task metadata. - Guided prompts and completion are shipped, but they do not execute or retain work. - Process permission elicitation is tracked separately in #96. - Ordinary progress and cancellation are tracked in #98. ## User problem Expensive work can exceed a comfortable tool-call lifetime. Agents cannot: - start work and continue other reasoning; - recover a result after a client reconnect; - poll durable phase status; - cancel through a stateful protocol; - distinguish waiting for user input from active computation; - retrieve completed evidence without re-running analysis. ## Proposed architecture ### 1. Internal operation model Introduce an SDK-independent operation state machine with queued, working, input_required, completed, failed, and cancelled states. Each operation should own: - cryptographically strong ID; - operation kind and normalized request identity; - originating session/authorization context; - created/updated timestamps; - bounded TTL; - status and safe status message; - progress state; - cancellation signal; - cleanup state; - final typed tool result or typed failure; - evidence IDs produced during execution. ### 2. MCP Tasks adapter When the client advertises the required Tasks capability: - accept a task-augmented tools/call; - return CreateTaskResult promptly; - implement tasks/get, tasks/result, tasks/list, and tasks/cancel; - attach io.modelcontextprotocol/related-task metadata to associated progress and elicitation; - bind task access to the originating connection or authorization context; - make tasks/result return exactly the underlying tool result. ### 3. Compatibility path For clients without Tasks: - retain current synchronous behavior; - use ordinary progress and cancellation from #98; - never advertise task-backed behavior that the client cannot consume. ### 4. Initial eligible operations Start with operations whose runtime or output justifies task execution: 1. binary/Hopper open and analysis; 2. exhaustive artifact inventory; 3. bounded process capture; 4. persistent cross-version investigation; 5. reconstruction verification; 6. large batch decompilation or comparison. Small navigation and read-only metadata calls should remain synchronous. ## Security and lifecycle requirements - Task IDs must be unguessable and scoped to the originating context. - tasks/list must not expose work across clients. - Cancellation must stop owned work and run verified cleanup. - Expired results must be deleted promptly. - Task results must retain Evidence v2 identity and limitations. - input_required must not be used to bypass permission policy. - An MCP disconnect may retain a task only when its authorization context remains safely recoverable; otherwise cancel it. - Concurrency and retained-byte limits must be enforced per client. ## Acceptance criteria - [ ] An internal operation abstraction exists independently of MCP SDK Tasks types. - [ ] Hopper analysis, artifact inventory, process capture, cross-version investigation, and reconstruction verification can run through it. - [ ] Capability-negotiated MCP Tasks support tasks/get, tasks/result, tasks/list, and tasks/cancel. - [ ] tasks/result is contract-equivalent to the corresponding synchronous tool result. - [ ] Status messages identify useful phases without exposing sensitive provider diagnostics. - [ ] Progress tokens continue across the task lifetime. - [ ] input_required can associate a permission elicitation from #96 with the task. - [ ] Cancellation propagates through providers and verifies cleanup. - [ ] Results have documented TTL, byte, and concurrency limits. - [ ] Task access is bound to the correct connection/authorization context. - [ ] Synchronous fallback remains fully supported. - [ ] Tests cover success, typed failure, cancellation, cancellation races, expiry, input_required, disconnect, result retrieval, unauthorized lookup, list isolation, and unsupported-client fallback. - [ ] Documentation marks the MCP Tasks surface experimental and identifies the supported protocol/SDK versions. ## Non-goals - Making every tiny REA tool asynchronous. - Treating Tasks as permanent evidence storage. - Allowing task execution to expand filesystem, executable, or network policy. - Depending on deprecated MCP sampling, roots, or logging. ## Dependencies - #98 for common progress/cancellation primitives. - #96 for scoped permission elicitation. - #99 for addressable retained evidence after task completion. ## July 2026 SDK and Tasks extension update REA currently pins the split MCP SDK packages at `2.0.0-beta.4`. Investigation of beta.3 and beta.4 found that their exported task schemas describe the experimental `2025-11-25` task design, but the SDK does not provide the former high-level task manager/runtime. Meanwhile, current MCP Tasks work has moved to the Extensions Track and uses a different evolving contract, including different operation and result shapes. The internal operation model in this issue remains required and should proceed independently of MCP wire types. The MCP adapter described above is now a historical target, not an implementation contract. Before implementing the public adapter: - select and document one exact Tasks extension revision and compatible SDK version; - reconcile `tasks/list` and `tasks/result` assumptions with the selected extension; - reconcile task capability negotiation, result discrimination, update/input flow, cancellation, and related-task metadata with that revision; - keep all extension-specific schemas and lifecycle translation in the MCP adapter; - retain synchronous fallback and ordinary progress/cancellation from #98; - add conformance tests proving the selected wire contract rather than relying only on exported TypeScript types. Acceptance criteria referring to specific task methods or metadata should be evaluated against the selected extension revision before implementation. No task capability should be advertised until REA implements and tests the complete selected contract.
bsakaguchi 2026-10-15 18:20:40 +00:00
Author
Owner

@morluto commented on GitHub (Jul 17, 2026):

Current external-contract research confirms this should remain open but must not target the removed experimental SDK API. The MCP TypeScript SDK v2 removed its prior experimental Tasks surface pending the SEP-2663 Tasks Extension. REA should first select and pin an exact extension revision, then implement an SDK-independent retained-operation state machine and conformance adapter while preserving the synchronous path. Progress and resource prerequisites are already shipped.

<!-- gh-comment-id:5001695839 --> @morluto commented on GitHub (Jul 17, 2026): Current external-contract research confirms this should remain open but must not target the removed experimental SDK API. The MCP TypeScript SDK v2 removed its prior experimental Tasks surface pending the SEP-2663 Tasks Extension. REA should first select and pin an exact extension revision, then implement an SDK-independent retained-operation state machine and conformance adapter while preserving the synchronous path. Progress and resource prerequisites are already shipped.
Author
Owner

@morluto commented on GitHub (Jul 20, 2026):

Split into focused child issues:

These replace the broad remaining scope in this issue. Closing this parent can happen once all children are closed.

<!-- gh-comment-id:5023447402 --> @morluto commented on GitHub (Jul 20, 2026): Split into focused child issues: - [ ] #390 - [ ] #391 These replace the broad remaining scope in this issue. Closing this parent can happen once all children are closed.
Author
Owner

@morluto commented on GitHub (Jul 20, 2026):

Closing as out of scope / premature for the current local CLI/MCP reverse-engineering focus: no supporting code exists, and these areas should be revisited only after in-tree providers and the public boundary are stable.

<!-- gh-comment-id:5023568882 --> @morluto commented on GitHub (Jul 20, 2026): Closing as out of scope / premature for the current local CLI/MCP reverse-engineering focus: no supporting code exists, and these areas should be revisited only after in-tree providers and the public boundary are stable.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#63
No description provided.