fix(ingest): narrow mcp_timeout to our OWN deadline, not the exception type (kø-z follow-up)

Advisor review of the prior commit (5269b7d) found the except TimeoutError
branch was wider than the brief asked for: builtin TimeoutError is also
socket.timeout (3.10+) and asyncio.TimeoutError (3.11+), so any TimeoutError
reaching that clause got relabeled mcp_timeout regardless of source. Gate on
anyio.CancelScope.cancelled_caught instead, mirroring _unwrap_ingest_error's
ownership rule (own it, wrap it; otherwise, untouched).

Measured: no live trigger exists today (MCP's own internal read-timeout
converts to McpError before reaching us; a server-side TimeoutError becomes
an ordinary isError result) -- pinned with a synthetic test raising from
StdioServerParameters construction, inside our fail_after scope but before
either nested task group, so it arrives ungrouped. Four mutations red against
the full 625-test suite: drop the translation, revert to asyncio.wait_for,
relabel the code, and drop the cancelled_caught gate.

Also promotes anyio to a declared direct dependency (was transitive via mcp
only) -- ingest_mcp.py now imports it directly.
This commit is contained in:
Kjell Tore Guttormsen 2026-08-03 21:22:00 +02:00
commit 8d1d29edf0
4 changed files with 64 additions and 10 deletions

2
uv.lock generated
View file

@ -1489,6 +1489,7 @@ dependencies = [
{ name = "agent-framework-foundry" },
{ name = "agent-framework-openai" },
{ name = "agent-framework-orchestrations" },
{ name = "anyio" },
{ name = "azure-identity" },
{ name = "llm-ingestion-okf" },
{ name = "mcp" },
@ -1511,6 +1512,7 @@ requires-dist = [
{ name = "agent-framework-foundry", specifier = ">=1.8.2" },
{ name = "agent-framework-openai", specifier = ">=1.8.2" },
{ name = "agent-framework-orchestrations", specifier = ">=1.0.0" },
{ name = "anyio", specifier = ">=4.14" },
{ name = "azure-identity", specifier = ">=1.25" },
{ name = "llm-ingestion-okf", git = "https://git.fromaitochitta.com/open/llm-ingestion-okf.git?rev=v0.3.1" },
{ name = "mcp", specifier = ">=1.28.0" },