Skip to content

fix: share task store across stateless HTTP requests in serve()#443

Merged
bokelley merged 2 commits intomainfrom
bokelley/fix-task-poll-stateless
Apr 8, 2026
Merged

fix: share task store across stateless HTTP requests in serve()#443
bokelley merged 2 commits intomainfrom
bokelley/fix-task-poll-stateless

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

@bokelley bokelley commented Apr 8, 2026

Summary

  • serve() created a new InMemoryTaskStore per HTTP request, so tasks/get on subsequent requests returned "Task not found" — breaking all async tool calls over stateless Streamable HTTP
  • Now serve() creates one shared task store and passes it to the factory via a new ServeContext parameter
  • Backward compatible: existing no-arg factories still work (JS ignores extra arguments)
  • Updated examples, docs (BUILD-AN-AGENT.md, llms.txt), and exports

Closes #442

Test plan

  • 7 new integration tests in test/lib/serve-tasks.test.js:
    • Sync tool over stateless HTTP
    • Async task lifecycle (create → poll → result) over stateless HTTP
    • Custom taskStore via ServeOptions
    • Same taskStore reference across all requests
    • Regression callToolStream task retrieval fails over stateless Streamable HTTP #442: task created on connection A retrievable on connection B
    • Backward compat: no-arg factory still works
  • All 8 existing serve.test.js tests pass
  • All 6 existing mcp-tasks-compat.test.js tests pass
  • Full suite: 1,499 tests pass, 0 failures

🤖 Generated with Claude Code

bokelley and others added 2 commits April 8, 2026 08:08
serve() created a new InMemoryTaskStore per request, so tasks/get on
subsequent requests returned "Task not found". Now serve() creates one
shared store and passes it to the factory via ServeContext.

Closes #442

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit 744c829 into main Apr 8, 2026
11 checks passed
@bokelley bokelley deleted the bokelley/fix-task-poll-stateless branch April 8, 2026 12:20
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.

callToolStream task retrieval fails over stateless Streamable HTTP

1 participant