Problem
When using openclaw_chat_async to submit a task and then polling openclaw_task_status, the status remains "running" for 10+ minutes even though the OpenClaw Gateway dashboard shows the task completed in ~1-2 minutes. Eventually the status does update to "completed", but the delay makes async task tracking unreliable.
Root Cause (from source code analysis)
After reading the source code, I found that openclaw_task_status never queries the Gateway for task status. It only reads from an in-memory Map<string, Task> in TaskManager (src/mcp/tasks/manager.ts). The task status is purely derived from the lifecycle of the local HTTP request to /v1/chat/completions:
- pending → task is in the local queue
- running → HTTP POST sent,
await-ing the response in processTask() (src/mcp/tools/tasks.ts)
- completed → HTTP response body fully received
The problem is that the Gateway may complete the internal task (visible on its dashboard) well before the /v1/chat/completions HTTP response is sent back. This creates a blind spot where the MCP server has no way to detect that the task is already done.
Additionally, the task processor is single-threaded and sequential — only one task runs at a time, and subsequent tasks are blocked until the current one's full HTTP roundtrip completes.
Suggested Improvements
-
Poll Gateway task status independently: Instead of relying solely on the blocking HTTP response, add a mechanism to periodically check the Gateway's internal task status (if it exposes such an endpoint) and update the local TaskManager accordingly.
-
Use streaming: Switch client.chat() from non-streaming to SSE streaming (stream: true) so partial progress can be detected and the response arrives incrementally.
-
Add concurrency: Replace the single-worker sequential loop with a configurable concurrency pool to process multiple tasks in parallel.
-
Make timeout configurable: The hardcoded DEFAULT_TIMEOUT_MS = 120_000 in client.ts should be configurable via environment variable or config.
Environment
- OpenClaw Gateway: v2026.5.12, running locally on
127.0.0.1:18789
- openclaw-mcp: latest (installed via npx)
- Client: Claude Desktop (Cowork mode)
Reproduction Steps
- Configure
openclaw-mcp with a local OpenClaw Gateway
- Send a complex task via
openclaw_chat_async (e.g., "summarize today's tech news" which requires web search and takes ~1-2 min on Gateway)
- Poll
openclaw_task_status every few seconds
- Observe that status stays
"running" for 10+ minutes
- Check Gateway dashboard — task shows as completed within 1-2 minutes
Problem
When using
openclaw_chat_asyncto submit a task and then pollingopenclaw_task_status, the status remains"running"for 10+ minutes even though the OpenClaw Gateway dashboard shows the task completed in ~1-2 minutes. Eventually the status does update to"completed", but the delay makes async task tracking unreliable.Root Cause (from source code analysis)
After reading the source code, I found that
openclaw_task_statusnever queries the Gateway for task status. It only reads from an in-memoryMap<string, Task>inTaskManager(src/mcp/tasks/manager.ts). The task status is purely derived from the lifecycle of the local HTTP request to/v1/chat/completions:await-ing the response inprocessTask()(src/mcp/tools/tasks.ts)The problem is that the Gateway may complete the internal task (visible on its dashboard) well before the
/v1/chat/completionsHTTP response is sent back. This creates a blind spot where the MCP server has no way to detect that the task is already done.Additionally, the task processor is single-threaded and sequential — only one task runs at a time, and subsequent tasks are blocked until the current one's full HTTP roundtrip completes.
Suggested Improvements
Poll Gateway task status independently: Instead of relying solely on the blocking HTTP response, add a mechanism to periodically check the Gateway's internal task status (if it exposes such an endpoint) and update the local
TaskManageraccordingly.Use streaming: Switch
client.chat()from non-streaming to SSE streaming (stream: true) so partial progress can be detected and the response arrives incrementally.Add concurrency: Replace the single-worker sequential loop with a configurable concurrency pool to process multiple tasks in parallel.
Make timeout configurable: The hardcoded
DEFAULT_TIMEOUT_MS = 120_000inclient.tsshould be configurable via environment variable or config.Environment
127.0.0.1:18789Reproduction Steps
openclaw-mcpwith a local OpenClaw Gatewayopenclaw_chat_async(e.g., "summarize today's tech news" which requires web search and takes ~1-2 min on Gateway)openclaw_task_statusevery few seconds"running"for 10+ minutes