Skip to content

mcpx: a cancelled task's inner call is not an unknown write outcome (#8922) - #11279

Merged
dezren39 merged 1 commit into
mainfrom
queue/20361-mcpx-conformance
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/20361-mcpx-conformance

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Refs #8922 (root-cause analysis posted on the issue before this PR, per the packet: #8922 (comment))

What was wrong

Post-#11188 conformance (run 44070866395) left server-all and server-2026-07-28 failing 17 checks each, every one in tasks-* scenarios. Reproduced locally against the pinned suite; three defects, one cascade:

  1. Cancelled task → unknown-write ledger record (the cascade). The capability scenario creates a task (slow_compute), then sends tasks/cancel as cleanup. The in-flight call aborts with a plain cancellation error; callWithLedger recorded an unknown write outcome (ledger: {server: "tasks", tool: "slow_compute", surface: "call"}), refusing every later non-read-only call to tasks and cascading through seven more scenarios. A tasks/cancel is a disposition the task store owns — the task reads back cancelled — so the outcome is accounted for, not unknown.
  2. Same recording on the interruptible (ask) surface. An asked call starts before its task exists, so no context mark can ride with it; the fix flags it retroactively via the abandon route ({"taskCancelled": true}), marked in the daemon's ask table before the cancel lands.
  3. Legacy task-augmented calls rejected in-line answers. failing_job (taskSupport required) is answered in line with a plain CallToolResult (isError) — permitted by the extension — but callToolAsLegacyTask called it malformed, and that synthetic error was recorded as an unknown outcome too. Substantive in-line results are now accepted; shapeless answers keep the malformed error (TestLegacyTaskFaultAndMalformed contract preserved).

The fix

  • mcpserver: export the within-task mark (MarkWithinTask/WithinTask); driveAsked abandons through a task-aware AbandonTask when the driver offers it.
  • mcpclient: WithTaskExecution/TaskExecutionFrom marker; in-line result acceptance above.
  • cli: direct and interruptible paths translate the mark; the daemon client serializes it as X-Mcpx-Task-Execution (mirroring X-Mcpx-Caller-Protocol).
  • daemon: header restored in withClientCaps, carried by value into ask-task contexts; abandon route flags the ask table; callWithLedger skips recording for a task inner call whose context was cancelled, on any path. Unmarked cancelled calls still record.

Verification

  • New tests: TestCallWithLedgerTaskCancellationDoesNotRecordUnknownOutcome (in-process + header-restored marks, unmarked control), TestCallWithLedgerAskTaskCancellationDoesNotRecordUnknownOutcome (flagged vs unflagged ask).
  • go test green: internal/daemon, internal/mcpclient, internal/mcpserver, internal/cli; go build ./....
  • Local conformance (pinned suite, taskmcp fixture): all 8 tasks scenarios pass — capability 5/5, dispatch 9/9, lifecycle 9/9, wire-fields 4/4, request-state-removal 3/3, mrtr-input 4/4, request-headers 5/5, mrtr-composition 2/2 — with no unknown-writes ledger file created.

Refs, not Fixes: #8922 closes only after a post-merge conformance run shows all nine legs green.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 12:20
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T12:20:12.374665Z
We couldn’t complete this review. Comment @codex review to try again.
016f9a4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7bfd5cfc-cebc-46ff-9094-5cc334c0fce8
Commits

Reviewing files that changed from the base of the PR and between fe8fb4a and acf422c.

Files selected for processing: 10

  • pkgs/mcpx/internal/cli/client.go
  • pkgs/mcpx/internal/cli/serve.go
  • pkgs/mcpx/internal/cli/serve_ask.go
  • pkgs/mcpx/internal/daemon/callerr.go
  • pkgs/mcpx/internal/daemon/registry.go
  • pkgs/mcpx/internal/daemon/routes_proto.go
  • pkgs/mcpx/internal/daemon/write_policy_test.go
  • pkgs/mcpx/internal/mcpclient/modern.go
  • pkgs/mcpx/internal/mcpclient/tasks.go
  • pkgs/mcpx/internal/mcpserver/tasks.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…8922)

The tasks-* conformance scenarios cascade-failed from one ledger
record: the suite creates a task, cancels it as cleanup, and the
in-flight upstream call aborts with a plain cancellation error, which
callWithLedger recorded as an unknown write outcome -- refusing every
later non-read-only call to that server. A tasks/cancel is a
protocol-level disposition owned by the task store (the task reads
back as cancelled), so the outcome is accounted for, not unknown.

The mark that a call is a task's inner call now reaches the ledger on
all three daemon call paths: in-process (mcpserver.WithinTask),
across the daemon API (X-Mcpx-Task-Execution, restored like the
caller-protocol header and carried by value into ask-task contexts),
and retroactively for interruptible (ask) calls -- an asked call
starts before its task exists, so the task's cancellation flags the
ask id through the abandon route before the cancel lands.

Also accept a substantive in-line CallToolResult from a legacy
task-augmented call: a server may answer at once when the tool
finishes immediately (the fixture's failing_job does), and the
synthetic malformed-response error was itself being recorded as an
unknown outcome. Shapeless answers keep the malformed error.

Unmarked cancelled calls still record, exactly as before.
@dezren39
dezren39 force-pushed the queue/20361-mcpx-conformance branch from 016f9a4 to acf422c Compare November 17, 2026 12:26
@dezren39

Copy link
Copy Markdown
Member Author

Review/verification status at merge time:

  • Codex: review failed to run — Codex usage limits for code reviews (its comment on this PR, 2026-11-17T12:20Z). No findings exist to disposition.
  • CodeRabbit: review limit reached (free OSS reviews exhausted; next included review ~19 min after its 12:20Z comment). No findings exist to disposition.
  • Local verification (commit acf422c): go build ./...; go test green for internal/daemon, internal/mcpclient, internal/mcpserver, internal/cli (full suites). Local conformance against the pinned suite + taskmcp fixture: all 8 tasks scenarios pass (capability 5/5, dispatch 9/9, lifecycle 9/9, wire-fields 4/4, request-state-removal 3/3, mrtr-input 4/4, request-headers 5/5, mrtr-composition 2/2) with no unknown-writes ledger file created.

Merging under the queue's standing criteria; the deciding verification for #8922 is the post-merge nine-leg conformance run, dispatched next.

@dezren39
dezren39 merged commit 4b9cd2b into main Nov 17, 2026
1 check passed
@dezren39
dezren39 deleted the queue/20361-mcpx-conformance branch November 17, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant