fix(coding-agent): restart dead kernels on ensure() and read mcp>=2 tool schemas - #2034
Open
snimu wants to merge 2 commits into
Open
fix(coding-agent): restart dead kernels on ensure() and read mcp>=2 tool schemas#2034snimu wants to merge 2 commits into
snimu wants to merge 2 commits into
Conversation
…ool schemas IpythonKernelProvisioner.ensure() cleared its memo only on startup failure, dispose, or kill; a kernel that died after a successful startup (OOM kill, os._exit) was handed out forever, wedging every later Python call. The memo now drops when the started kernel is no longer running, so the existing startKernel path (snapshot restore included) reruns. Separately, mcp>=2 renamed the Tool schema field to input_schema; mcp_base.py read only the inputSchema alias, so every skill-MCP tool advertised an empty schema. It now mirrors mcp.py's dual lookup.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b94d987. Configure here.
Protocol repair cycles the same manager through idle/starting while it respawns its child; the broad !isRunning check would abandon it and start a second kernel over the same snapshot directory. The memo now drops only for a defunct (shutdown-state) manager - the state an unexpected child exit parks in permanently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Two Python-runtime defects:
IpythonKernelProvisioner.ensure()memoizes the started kernel and cleared that memo only on startup failure, dispose, or kill. A kernel that died after a successful startup (OOM kill,os._exit, crash) was handed to every later Python call forever — each one failing against a dead process until the session restarted.ensure()now drops the memo when the started kernel is no longer running, so the existing startup path (snapshot restore included) reruns on the next call. Fixes the defect reported in discussion [Bug] v0.8.0 stopped IPython kernel remains permanently cached after unexpected exit #1659.mcp>=2renamed the Tool schema field toinput_schema(withinputSchemaas the wire alias); pydantic attribute access is by field name, somcp_base.py'sgetattr(t, "inputSchema", ...)was alwaysNoneand every skill-MCP tool advertised an empty{}schema — models called tools blind. The lookup now mirrors the dual lookup its siblingmcp.pyalready uses. Fixes the defect reported in discussion Fix: McpIntegration.list_tools() always returns empty inputSchema (#1073) #1757.Validation
input_schemasurfaces its schema throughlist_tools()(pre-fix:{})ipython-provisioner(20) andtest_mcp_base(18 viauv run python -m unittest) — greennpm run checkpasses via the pre-commit hookLOC
Src +14/−5 (both point fixes; the kernel fix is a 4-line liveness check ahead of the existing memo, the schema fix mirrors the sibling module's lookup). Tests +42, changelog 1 fragment.
Linear: RES-1266 https://linear.app/primeintellect/issue/RES-1266
Note
Medium Risk
Changes Python kernel provisioning after crashes (session recovery path) and MCP tool metadata exposed to models; behavior is narrow and tested but touches execution reliability.
Overview
Fixes two runtime issues: dead Python kernels wedging sessions and empty MCP tool schemas under mcp>=2.
Kernel lifecycle: Adds
isDefunctonKernelClient/ReplKernelManager(terminalshutdownstate).IpythonKernelProvisioner.ensure()now clears its memoized manager when the started kernel is defunct, so the next Python call goes through normal startup (including snapshot restore) instead of reusing a crashed process. Kernels that are only temporarily not running—e.g. mid protocol repair—stay memoized because they are not defunct.Skill MCP:
McpIntegration._ensure_toolsinmcp_base.pyresolves tool input schemas viainput_schemafirst, theninputSchema, matchingmcp.py. Only dict-shaped schemas are exposed inlist_tools()metadata.Tests cover defunct vs repairing memo behavior and snake_case schema surfacing; changelog fragment added.
Reviewed by Cursor Bugbot for commit b7e45c4. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Restart dead kernels on
ensure()and readinput_schemafor mcp>=2IpythonKernelProvisioner.ensurechecks the newisDefunctgetter on cached kernel managers. If defunct, it clears the memo and starts a fresh Python process; non-defunct managers stay memoized even during protocol repair.McpIntegration._ensure_toolsreads the mcp>=2input_schemaattribute first, falling back toinputSchema. The resolved schema remains exposed under the existinginputSchemametadata key.Macroscope summarized b7e45c4.