Repository navigation
Description
Filed at the owner's request from the 2026-10-09 review of GitHub Actions warnings and notices.
Problem
Checked at release/v0.2.32 (27cf6bd).
- CI run https://github.com/dan-petty/devops-cli/actions/runs/37939949186/job/113851481357 (release/v0.2.31 at a6ac3f0, the same tree) reports
PydanticJsonSchemaWarning: Default value <fastmcp.server.dependencies._OptionalCurrentContext object ...> is not JSON serializable; excluding default from JSON schema [non-serializable-default]. It appears intests/test_ai_cmd.py::test_ai_extended_commandsand::test_ai_token_count_route_pipeline_bundle. - The stack captured at pydantic's
GenerateJsonSchema.emit_warningruns fromdevops ai pipeline(commands/ai.py:1252get_default_tools(),:1268) →MultiAgentPipeline.add_agent(ai/agents/pipeline.py:228) →add_tool(ai/agents/agent.py:592) →Tool.from_function(ai/tools/__init__.py:208) → pydantic-aifunction_schema[measured]. get_mcp_agent_tools(ai/tools/mcp_bridge.py:12-22) gives agents the rawfnof every FastMCP tool: 181 of the 204 default tools [measured].get_persona_toolsfalls back to the same list (ai/tools/registry.py:165).- FastMCP 4.0.11 rewrites the signature of a function that takes a Context in place.
hydrate_tool_domain(domain: str, ctx: Context | None = None)(ai/mcp/server.py:3246-3247) ends up withctx=OptionalCurrentContext()as its default (fastmcp/server/dependencies.py:433-434). - As a result, the pydantic-ai tool built from it offers the model a
ctxargument. Its parameters schema is{domain, ctx: anyOf[$ref Context, null]}, with FastMCP's wholeContextdocstring under$defs: 2,164 characters. FastMCP's own published schema for the same tool (mcp.get_tool("hydrate_tool_domain").parameters) has onlydomain[measured]. Every pipeline stage sends this schema to the model. hydrate_tool_domainis the only MCP tool that takes aContexttoday [measured]. Any future tool that takes one would leak the same way.- Reproduce:
uv run pytest -p no:cacheprovider -q -n 0 --no-cov -W error::pydantic.json_schema.PydanticJsonSchemaWarning tests/test_ai_cmd.pyfails those 2 tests [measured].
Proposed remedy
In get_mcp_agent_tools, wrap each fn in FastMCP's fastmcp.server.dependencies.without_injected_parameters. FastMCP provides this helper for schema generation. It drops Context and Depends parameters from the signature and injects them at call time, so with no MCP session ctx resolves to None. For hydrate_tool_domain, the wrapped tool's schema equals FastMCP's published schema [measured].
The larger alternative is to give agents the in-process MCP toolset (get_devops_mcp_toolset()). #857 and #997 touch the same bridge, so this change stays limited to the wrapper.
Acceptance criteria
- A test checks every MCP-derived tool in
get_default_tools(): its pydantic-ai parameters schema equals the schema FastMCP publishes for the same tool. - Called through the agent tool with no MCP session,
hydrate_tool_domainstill returns its result. - The reproduction above passes, and the CI pytest summary has no
PydanticJsonSchemaWarning. -
uv run devops cipasses.
Related: #857 (approval on the same default tools), #997, #1330 (tool tests on edge fakes).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty-bot commentedon Oct 9, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
It degrades model tool-calling quality and produces CI warnings, but only one tool is affected today and the tool still functions with ctx resolving to None.The failed run 37939949186 does not set P0: no failed run of this repository has that id. A person can set P0 on the board.Fixing it removes a spurious parameter and 2 KB of schema noise from every pipeline stage's model context, and prevents the same leak for any future Context-taking tool.The remedy is wrapping each fn with fastmcp's without_injected_parameters helper in get_mcp_agent_tools plus a schema-equality test, a small localized change.fix(ai): strip fastmcp injected ctx parameter from mcp agent tools (#…
dan-petty commentedon Oct 21, 2026
What changed
#1767, merged into
release/v0.2.38as be39289.5 file(s) changed.
How it was verified
Check runs at c740049:
Acceptance Criteria of
docs/agent/tasks/task-1498-mcp-toolset-strip-ctx.md:No Acceptance Criteria section.
feat(release): v0.2.38 (#1799)
feat(release): v0.2.38 (#1798)