Repository navigation
refactor(narratives): rename the mcp turn stage and config keys to discovery - #538
Conversation
There was a problem hiding this comment.
Code Review
This pull request systematically renames references to 'mcp' to 'discovery' across the narratives agent codebase, including configuration models, schemas, workflows, telemetry, server routes, UI components, tests, and documentation. Key changes include renaming mcp_model to discovery_model, mcp_level to discovery_level, GeminiRole.MCP to GeminiRole.DISCOVERY, and run_mcp_phase to run_discovery_phase. I have no feedback to provide as there are no review comments.
juliawu
left a comment
There was a problem hiding this comment.
Thanks! This looks good. Adding one more instance in chat.py found by Gemini:
narratives/agent/src/narratives_agent/server/routes/chat.py:97 — [NIT] Stale phase name in _turn_events docstring. Line 97 still says "because the MCP phase reports model thoughts through a callback", whereas that phase is now the discovery phase. Update "the MCP phase" to "the discovery phase".
Overview
Before this PR, the Narratives application overloaded the identifier
mcpfor two distinct concepts: the Model Context Protocol client and server transport (McpConfig,narratives_agent/mcp/, andworkflows/mcp_loop.py) and the data-gathering stage of a chat turn acrossGeminiRole.MCP,gemini.mcp_model,thinking.mcp_level,prompts.mcp,defaults/prompts/mcp.md, SSE"phase": "mcp"frames,TurnTelemetryphase spans, and the React UI.This PR renames the data-gathering turn stage and its configuration keys, prompt file,
GeminiRole, SSE phase, telemetry span, and UI status handling frommcptodiscovery, while keeping the MCP protocol and transport layer (McpConfig,narratives_agent/mcp/,workflows/mcp_loop.py, MCP error codes,TurnTelemetry.mcp_iterations, and the/agent/health"mcp"key) namedmcp.Note: Looks bigger than it is, as it touches many files, but it is trivial.
Related Issues
Changes Made
mcp->discovery): Renames the data-gathering stage and itsGeminiRolefrommcptodiscoveryacrossAgentConfig(gemini.discovery_model,thinking.discovery_level,prompts.discovery), the default prompt file (defaults/prompts/discovery.md), the JSON schema and example configs, SSEstatusandthoughtphase payloads,TurnTelemetryphase spans, and the React UI, while keeping MCP protocol/server configuration (McpConfig) and transport identifiers namedmcp.docs/architecture.md, anddocs/deployment.mdto match thediscoverystage name and configuration keys.Testing Done
pnpm test:agent(uv run pytest): 826 passed (matchesnarratives-gemini-rolesatb322d698).pnpm test:ui(vitest run): 26 files, 286 passed.pnpm lint:ui(tsc --noEmitandbiome check): passed across 48 checked files.pnpm lint:agent(ruff format --check,ruff check, andmypy --strict): passed across all 64 source files with no overrides.pnpm lint:deploy:terraform fmt -check,shellcheck, andhadolintpassed (terraform validatehas a pre-existing local Terraform 1.15 backend-config error unrelated to this PR; nodeploy/files are modified).pnpm build: compiled the UI bundle intoui/dist/and stagedui/dist/intoagent/static/anddefaults/(includingdefaults/prompts/discovery.md) intoagent/defaults/with a cleangit status -s.npx --yes -p ajv-cli@5.0.0 -p ajv-formats@3.0.1 ajv validate --spec=draft2020 --strict=false -c ajv-formats -s schemas/agent-config.schema.json -d defaults/agent-config.jsonand-d schemas/agent-config.example.json: both valid.Checklist:
"mcp"/mcp_model/mcp_levelto"discovery"/discovery_model/discovery_level)Manual
Tested with
pnpm dev:agentandpnpm dev:ui:defaults/agent-config.jsonanddefaults/prompts/discovery.mdand submitted"What is the population of France?"and"How has the population of California changed since 2010?". Verified in the network inspector that/agent/chatemittedstatus({"phase": "discovery", "message": "Querying data tools..."}) andthought({"phase": "discovery", ...}) SSE events, the UIReasoningBlockand response card skeleton transitioned throughclassify->discovery->synthesis->donewithout visual changes, and the turn telemetry log recordedphases_ms.discovery.Risk & Rollback
There are no active production deployments of Narratives. Rollback is reverting the PR.
Follow-ups
GeminiConfig(synthesis_model,chart_config_model,follow_up_model) and continue with the agent loop updates.Checklist
AGENTS.mdand followedCODING_GUIDELINES.md, plusFRONTEND.mdfor UI changes.Note: Only Maintainers can approve and merge PRs. Expected initial review time: 3 business days.