Skip to content

Ask agents' questions in the agent's client, also through app calls - #536

Merged
tnkuehne merged 4 commits into
mainfrom
mcp-question-runner
Dec 1, 2026
Merged

tnkuehne merged 4 commits into
mainfrom
mcp-question-runner

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

A question now reaches the person where they started the work. Since #534, questions from app calls appear on the calling app's open pages. That is right when a person clicks in the app, but an agent that calls an app through Widefleet MCP had no page: the question was cancelled, and the agent received the API's declined result. Now, when an agent calls an app and that app calls an API that asks — for example a CRM that sends mail through the Gmail template — the question appears in the agent's client. The app waits, then continues with the answer without running again, and its code still never handles questions.

How it works

  • Runs: every MCP call and execute runs apart from the request that started it. McpRunner (a Durable Object per run) starts the run through a McpRun entrypoint and keeps it going. McpQuestions (a Durable Object per run) takes the run's questions and the answers. The two are separate objects because a run that calls back into the object that started it waits for itself on celld.
  • Questions: a provider called directly by the run, and any API the run reaches through app bindings, ask the run's questions object. The caller proof carries the run through every hop, so the binding gateway sends the question there instead of to app pages. Calls a person makes from an app's page keep the page dialog from Ask people the questions of app APIs on the calling app's open pages #534.
  • Answers: the MCP response is the existing native input_required, or the ask/answer form for clients without their own dialog. The answer, from the client's retry or the form, settles the waiting question, and the response carries the run's next question or its result. Each question token is bound to the person and answers only on its own channel: the client's retry, the agent's request to show the form, or the form itself.
  • Programs: execute suspends the program while any question of its run waits, also one from an app the program called, using CodeMode's snapshots and durable tool calls. The person's time does not count toward the 30-second limit, and the program resumes with the answer. A run that ends cancels its waiting questions.
  • Access: an answered call checks the person's access to the app again before it runs. Runs reuse the claims their request verified, so a company token is exchanged once per request.
  • Limits: a question waits up to five minutes and never past the agent's credential; a run that is lost after 14 minutes reports that instead of waiting.
  • Removed: the sealed requestState handling (sealInput, openInput, rebindInput) and its contracts. ask and answer take only the question token.
  • Types: a patch for @cloudflare/workers-types passes JSON-like RPC results by value without recursing through the serializability check and pipelining types, which never ends for recursive types such as a JSON value ("Type instantiation is excessively deep and possibly infinite", unidentified DO types, attempting to get a clean type from DO RPC Call cloudflare/workerd#3063). Other results keep their types. The run objects exchange typed events.
  • Configuration: WIDEFLEET_MCP_RUNNERS and WIDEFLEET_MCP_QUESTIONS (wrangler migration v7, and the self-hosted runtime configuration).

Tests

  • app-services-runtime.test.ts on workerd and celld: native dialog questions and form questions, including management; an answer from another person, a second answer, a relayed token on the form and a program token on a call are refused; an agent calls an app that calls a provider that asks, through call and through execute, and the app's effect before the question runs once; an app's question answered after 31 seconds still completes the program; a program that ends while a question waits does not show it; an answer after the person lost access is refused.
  • New unit tests for validating answers against the question's form.
  • Cloudflare runtime and dynamic celld suites, MCP management and MCP login runtime suites, cargo test -p platform-agent runtime, pnpm check (except the HubSpot lint error on main).

Not covered by tests: a run interrupted by a Durable Object restart, and the real Cloudflare edge. A client that disconnects no longer stops a running program on self-hosted celld; on Cloudflare it never did, because the runtime's compatibility date predates request.signal. A spike verified that a runner keeps an app waiting for 70 seconds after the first request ended, on workerd and celld.

A question reaches the person where they started the work. When an agent calls
an app through Widefleet MCP and that app calls an API that asks, the question
now appears in the agent's client, through its own dialog or the form, instead
of on the app's pages; the app waits and continues with the answer without
running again.

Each MCP `call` and `execute` runs apart from its request: a runner object keeps
the run going, and a questions object takes the run's questions and the answers
from the client's retry or the form. The caller proof carries the run through
app hops, so the binding gateway sends questions to it. A program is suspended
while a question waits, so the person's time does not count toward its time
limit. Question tokens answer only on their own channel; the sealed input
state and its contracts are removed.
…ess on answers

A program now pauses while any question of its run waits, also one from an app
it called, so the person's time never counts toward its time limit. A run that
ends cancels its waiting questions instead of showing them. An answered call
checks the person's access to the app again before it runs. Runs reuse the
claims their request verified, so a company token is exchanged once.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs e0263c8 Dec 01 2026, 03:26 PM

Workers RPC result types recurse without end for recursive types such as a
JSON value (cloudflare/workerd#3063). A patch passes JSON-like results by value
without recursing through the serializability check and pipelining types; other
results keep their existing types. The run's question object and runner now
exchange typed events instead of JSON text.
@tnkuehne
tnkuehne merged commit 59255d9 into main Dec 1, 2026
12 of 15 checks passed
@tnkuehne
tnkuehne deleted the mcp-question-runner branch December 1, 2026 15:29
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