Summary
When using the Codepilot Runtime (codepilot_runtime), two distinct issues are observed:
-
MCP server loading is incomplete: Only a subset of configured MCP servers are synced to the agent loop. The third-party MCP server (codepilot-image-gen) is consistently missing from the tool list, while only playwright and pencil are loaded.
-
Session becomes unrecoverable after interrupt: Interrupting the agent mid-response causes the session to enter a permanently broken state, with Tool result is missing errors persisting across all subsequent turns.
Environment
- Codepilot version: 0.64.0 (upgraded from 0.63.0 on this session start)
- OS: Windows 11 Pro 10.0.22621
- Runtime mode:
codepilot_runtime (pinned in session)
- Project path:
C:\Users\Administrator\codepilot
Issue 1: MCP servers not fully loaded
Observed behavior
Every agent loop turn logs the same line:
[agent-loop] Syncing 2 MCP servers: playwright, pencil
Only 2 MCP servers are synced. The tool list for the agent contains 58 tools total, consisting of built-in tools + Playwright MCP tools + Pencil MCP tools. No tools from the codepilot-image-gen MCP server are present.
Evidence
Log excerpt (repeated across all 7 turns in the session):
[agent-loop] Syncing 2 MCP servers: playwright, pencil
[agent-loop] Session 5857d9d0e7910ef2d8eebd4286c78124: model=deepseek-v4-flash, tools=[Read, Write, Edit, Bash, Glob, Grep, Skill, Agent, codepilot_dashboard_pin, ..., mcp__playwright__*, mcp__pencil__*] (58 total)
The codepilot-image-gen MCP tools are consistently absent from all 58-tool listings across all turns (lines 96, 120, 137, 181, 203, 222, 247, 272, 299, 317 of the log).
Related error
Every turn also logs:
[harness-home] Canonical projection failed { runtimeId: 'codepilot_runtime', reason: 'r is not a function' }
This error occurs on every single request (7 occurrences in the session log). It precedes the tool listing and may be related to the MCP loading failure.
Comparison: Claude Code Runtime works correctly
Under the same working directory, same MCP configuration, and same machine, using the Claude Code CLI Runtime:
codepilot-image-gen MCP server is loaded automatically on session start
- Agent can directly invoke
codepilot_generate_image without any searching or manual configuration
- MCP log confirms successful tool execution:
Tool 'codepilot_generate_image' completed successfully in 34s
Issue 2: Session unrecoverable after interrupt
Observed behavior
When the user interrupts the agent mid-response, the session enters a state where all subsequent turns fail with:
[agent-loop] streamText error: Tool result is missing for tool call call_7718bc899ed247aea103f200.
[agent-loop] Error: No output generated. Check the stream for errors.
Evidence
Interrupt log:
[codex.runtime] interrupt (route) — no active turn for 5857d9d0e7910ef2d8eebd4286c78124
[interrupt] fan-out { sessionId: '5857d9d0...', attempted: { native: true, codex_runtime: true, sdk: false } }
After the interrupt, the user sent 6 more messages. All of them failed with the same Tool result is missing error. Even switching the model (from deepseek-v4-flash to doubao-seed-2.1-turbo to claude-sonnet-5) and provider did not recover the session. The error persisted across model changes, and the sdk_session_id was repeatedly cleared and reset.
The session eventually became so broken that the user had to open a new session (478f123a...), but even that new session showed the same MCP loading issue (only 2 MCP servers synced).
Root cause analysis (speculative)
The recurring [harness-home] Canonical projection failed { runtimeId: 'codepilot_runtime', reason: 'r is not a function' } error suggests:
- The
harness-home module (likely responsible for resolving the home directory / config path for the agent harness) is failing during canonical projection — a path normalization operation
- The error
'r is not a function' indicates a JavaScript runtime error, possibly a function reference that was expected but not found (e.g., a callback, a method on a config object, or a module export)
- This failure may prevent the MCP configuration from being fully discovered and loaded, since MCP server definitions typically reside in the home directory config
Suggested investigation areas
-
harness-home module: Examine the canonical projection function for the runtimeId: 'codepilot_runtime' code path. The 'r is not a function' error suggests a variable r is expected to be a function but is undefined or of a different type.
-
MCP server discovery: Compare how the Codepilot Runtime discovers MCP servers vs. the Claude Code Runtime. The Codepilot Runtime may be using a different config resolution strategy that doesn't pick up all MCP servers.
-
Interrupt recovery: The interrupt handler attempts recovery via native and codex_runtime but neither succeeds. The Tool result is missing error suggests the interrupt left the tool call state machine in an inconsistent state.
-
MCP server definition location: The codepilot-image-gen MCP server is only referenced in the project's settings.local.json permissions list. Its mcpServers definition may be in a non-standard location that the Codepilot Runtime doesn't check.
Configuration files
Project settings.local.json:
{
"permissions": {
"allow": [
"mcp__codepilot-image-gen__codepilot_generate_image"
]
}
}
Global ~/.claude/settings.json: Contains env vars, plugin config, theme, and permissions — but no mcpServers section relevant to codepilot-image-gen.
Log reference
- Session ID:
5857d9d0e7910ef2d8eebd4286c78124 (broken session)
- Log file:
%APPDATA%\codepilot\logs\codepilot-main.log
- MCP log (working):
%LOCALAPPDATA%\claude-cli-nodejs\Cache\C--Users-Administrator-codepilot\mcp-logs-codepilot-image-gen\2026-08-03T05-34-03-041Z.jsonl
Summary
When using the Codepilot Runtime (codepilot_runtime), two distinct issues are observed:
MCP server loading is incomplete: Only a subset of configured MCP servers are synced to the agent loop. The third-party MCP server (
codepilot-image-gen) is consistently missing from the tool list, while onlyplaywrightandpencilare loaded.Session becomes unrecoverable after interrupt: Interrupting the agent mid-response causes the session to enter a permanently broken state, with
Tool result is missingerrors persisting across all subsequent turns.Environment
codepilot_runtime(pinned in session)C:\Users\Administrator\codepilotIssue 1: MCP servers not fully loaded
Observed behavior
Every agent loop turn logs the same line:
Only 2 MCP servers are synced. The tool list for the agent contains 58 tools total, consisting of built-in tools + Playwright MCP tools + Pencil MCP tools. No tools from the
codepilot-image-genMCP server are present.Evidence
Log excerpt (repeated across all 7 turns in the session):
The
codepilot-image-genMCP tools are consistently absent from all 58-tool listings across all turns (lines 96, 120, 137, 181, 203, 222, 247, 272, 299, 317 of the log).Related error
Every turn also logs:
This error occurs on every single request (7 occurrences in the session log). It precedes the tool listing and may be related to the MCP loading failure.
Comparison: Claude Code Runtime works correctly
Under the same working directory, same MCP configuration, and same machine, using the Claude Code CLI Runtime:
codepilot-image-genMCP server is loaded automatically on session startcodepilot_generate_imagewithout any searching or manual configurationTool 'codepilot_generate_image' completed successfully in 34sIssue 2: Session unrecoverable after interrupt
Observed behavior
When the user interrupts the agent mid-response, the session enters a state where all subsequent turns fail with:
Evidence
Interrupt log:
After the interrupt, the user sent 6 more messages. All of them failed with the same
Tool result is missingerror. Even switching the model (from deepseek-v4-flash to doubao-seed-2.1-turbo to claude-sonnet-5) and provider did not recover the session. The error persisted across model changes, and thesdk_session_idwas repeatedly cleared and reset.The session eventually became so broken that the user had to open a new session (
478f123a...), but even that new session showed the same MCP loading issue (only 2 MCP servers synced).Root cause analysis (speculative)
The recurring
[harness-home] Canonical projection failed { runtimeId: 'codepilot_runtime', reason: 'r is not a function' }error suggests:harness-homemodule (likely responsible for resolving the home directory / config path for the agent harness) is failing duringcanonical projection— a path normalization operation'r is not a function'indicates a JavaScript runtime error, possibly a function reference that was expected but not found (e.g., a callback, a method on a config object, or a module export)Suggested investigation areas
harness-homemodule: Examine thecanonical projectionfunction for theruntimeId: 'codepilot_runtime'code path. The'r is not a function'error suggests a variableris expected to be a function but isundefinedor of a different type.MCP server discovery: Compare how the Codepilot Runtime discovers MCP servers vs. the Claude Code Runtime. The Codepilot Runtime may be using a different config resolution strategy that doesn't pick up all MCP servers.
Interrupt recovery: The
interrupthandler attempts recovery vianativeandcodex_runtimebut neither succeeds. TheTool result is missingerror suggests the interrupt left the tool call state machine in an inconsistent state.MCP server definition location: The
codepilot-image-genMCP server is only referenced in the project'ssettings.local.jsonpermissions list. ItsmcpServersdefinition may be in a non-standard location that the Codepilot Runtime doesn't check.Configuration files
Project
settings.local.json:{ "permissions": { "allow": [ "mcp__codepilot-image-gen__codepilot_generate_image" ] } }Global
~/.claude/settings.json: Contains env vars, plugin config, theme, and permissions — but nomcpServerssection relevant tocodepilot-image-gen.Log reference
5857d9d0e7910ef2d8eebd4286c78124(broken session)%APPDATA%\codepilot\logs\codepilot-main.log%LOCALAPPDATA%\claude-cli-nodejs\Cache\C--Users-Administrator-codepilot\mcp-logs-codepilot-image-gen\2026-08-03T05-34-03-041Z.jsonl