mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-12 23:19:36 +00:00
* feat(mcp): add durable task runtime foundation * fix(chart): sync embedded config version * fix(mcp): isolate task polls during shutdown * feat(mcp): track consecutive poll errors on mcp_tasks poll_attempt_count grows on every claim (successful polls included), so it cannot drive a failure backoff without misjudging normal long tasks. Add consecutive_poll_error_count: incremented when a claim is released after a poll error, reset to zero by any applied snapshot. The backoff/terminal policy that consumes it lands with the first concrete driver. * fix(mcp): harden durable task lifecycle * fix(mcp): preserve tracked task on dedup conflict --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Protocol
|
|
|
|
from deerflow.mcp.tasks.models import TaskReference, TaskSnapshot, TaskSubmission, TaskSubmitRequest
|
|
|
|
|
|
class McpTaskDriver(Protocol):
|
|
"""Transport/protocol adapter used by the protocol-neutral task runtime."""
|
|
|
|
async def submit(self, request: TaskSubmitRequest) -> TaskSubmission: ...
|
|
|
|
async def get_status(self, task: TaskReference) -> TaskSnapshot: ...
|
|
|
|
async def cancel(self, task: TaskReference) -> TaskSnapshot: ...
|
|
|
|
|
|
class McpTaskDriverRegistry:
|
|
"""Process-local driver catalog wired at Gateway startup."""
|
|
|
|
def __init__(self) -> None:
|
|
self._drivers: dict[str, McpTaskDriver] = {}
|
|
|
|
def register(self, name: str, driver: McpTaskDriver) -> None:
|
|
normalized = name.strip()
|
|
if not normalized:
|
|
raise ValueError("driver name must not be empty")
|
|
if normalized in self._drivers:
|
|
raise ValueError(f"MCP task driver {normalized!r} is already registered")
|
|
self._drivers[normalized] = driver
|
|
|
|
def get(self, name: str) -> McpTaskDriver | None:
|
|
return self._drivers.get(name)
|
|
|
|
def names(self) -> tuple[str, ...]:
|
|
return tuple(sorted(self._drivers))
|