fix(awooop): initialize mcp runtime for signal worker
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 1m14s
CD Pipeline / build-and-deploy (push) Successful in 3m24s
CD Pipeline / post-deploy-checks (push) Successful in 1m30s

This commit is contained in:
Your Name
2026-05-18 12:03:15 +08:00
parent df7d957310
commit 98a10cbc7b
3 changed files with 68 additions and 0 deletions

View File

@@ -448,6 +448,7 @@ async def _add_observation_timeline(
async def _run_pre_decision_investigation(incident: "Incident") -> int | None:
started = time.monotonic()
try:
await _ensure_signal_observation_mcp_runtime()
from src.services.pre_decision_investigator import get_pre_decision_investigator
await asyncio.wait_for(
@@ -471,6 +472,33 @@ async def _run_pre_decision_investigation(incident: "Incident") -> int | None:
return int((time.monotonic() - started) * 1000)
async def _ensure_signal_observation_mcp_runtime() -> None:
"""Make one-off signal observation runs use the same MCP runtime as API startup."""
try:
from src.plugins.mcp.providers import register_all_providers
from src.plugins.mcp.registry import get_provider_registry
from src.services.mcp_tool_registry import get_mcp_tool_registry, init_mcp_tool_registry
provider_registry = get_provider_registry()
if len(provider_registry) == 0:
register_all_providers()
logger.info("signal_observation_mcp_providers_registered")
tool_registry = get_mcp_tool_registry()
if tool_registry.tool_count == 0:
await init_mcp_tool_registry()
logger.info(
"signal_observation_mcp_tool_registry_initialized",
providers=tool_registry.provider_count,
tools=tool_registry.tool_count,
)
except Exception as exc:
logger.warning(
"signal_observation_mcp_runtime_init_failed",
error=str(exc),
)
async def record_signal_worker_observation(
incident: "Incident",
signal_data: dict[str, Any],