fix(coding-agent): restart dead kernels on ensure() and read mcp>=2 tool schemas - #2034
Closed
snimu wants to merge 4 commits into
Closed
fix(coding-agent): restart dead kernels on ensure() and read mcp>=2 tool schemas#2034snimu wants to merge 4 commits into
snimu wants to merge 4 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.
Contributor
sethkarten
added a commit
that referenced
this pull request
Sep 7, 2026
) * refactor(coding-agent): move the semantic-edge ledger onto the event-log substrate The recorder's private append/replay/repair IO is deleted; EventLog owns it, the same move #1987 made for the RLM spawn ledger. One durability rule is unified in the substrate rather than dropped: an unterminated final line is an uncommitted append, skipped on read and truncated before the next append — never newline-completed and never surfaced to a consumer whose next append destroys it. * fix(coding-agent): make the explicit ledger reader's ENOENT contract atomic readSemanticEdgeLedger probed with statSync before reading through EventLog, which swallows ENOENT; a ledger deleted between the two returned [] instead of throwing. The missing-file decision now lives at the single open (replaySync missingFileThrows), so no check-then-read window exists. * docs(coding-agent): state the event-log tail rule once The unterminated-tail contract was restated four times (module doc, replaySync doc, two test comments). It now lives once in the module doc; the method doc keeps only its own parse/missing-file semantics and the test comments reference the contract. * fix(coding-agent): write event-log appends fully and gate appends on tail repair writeSync may write short (ENOSPC after a prefix); appendSync now loops until the payload is fully on disk so write-before-action callers never act on a torn record reported as success. A tail-repair failure (e.g. append-only ACL permitting O_APPEND but not r+) now propagates instead of being swallowed: writing through an unrepaired torn tail would weld it to the new record as permanent interior corruption. ENOENT and the concurrent-writer instability path keep their existing semantics. * fix(coding-agent): reclaim short event-log writes instead of completing them The rlm spawn ledger is multi-writer by documented design (supervisor plus each worker over one file), so completing a short O_APPEND write with a second write could interleave with a rival append and weld two records. A short write now truncates its own torn prefix back off (only while this writer still owns the tail) and fails the append; a torn tail is read-tolerated, a weld is permanent corruption. The append fd opens a+ so the ownership check can read the tail. * fix(coding-agent): leave the torn tail on a short write instead of reclaiming it The tail-match reclaim could truncate a rival's committed record whose final bytes coincide with our torn prefix - committed-data loss, strictly worse than the torn tail it prevented. A short write now just fails the append: the torn tail is the one tolerated shape, skipped on read and truncated by any writer's next repair (verified for both topologies: a resumed single-writer recorder repairs on its first append; every rlm-ledger writer repairs before each append). * refactor(coding-agent): compress event-log comments * fix(ai): omit the default service tier, reprice cache writes from message_delta, repoint the zai default Incorporates #2032 at f82c7fa. * fix(tui,coding-agent): survive lone surrogates in table cells and terminate the WebP EXIF scan Incorporates #2033 at a3d1139. * fix(coding-agent): restart dead kernels on ensure() and read mcp>=2 tool schemas Incorporates #2034 at 749e216. * fix: one crash-safe owner for durable state writes Incorporates #2035 at f0f02d2. * fix(coding-agent): one zombie-aware process-liveness probe Incorporates #2041 at 92a0eac. * fix(coding-agent): snapshot transfer ids from the materialized cursor; mismatches settle the transfer, not the worker channel Incorporates #2044 at 5af3bbe. * fix(coding-agent): failed workers recover on touch; roster gaps answer a structured recovering error Incorporates #2047 at 77b747a. * fix(coding-agent): seven session and IO correctness defects Incorporates #2037 at 41b5d72. * fix(coding-agent): coalesce child-usage attribution and gate agent-status persistence on real changes Incorporates #2050 at 6b0af5d. * fix(coding-agent): incremental single-flight session metadata scans Incorporates #2043 at df032c1. * fix(coding-agent): memoize the passive RLM topology derivation Incorporates #2051 at 0ee114c. * fix(coding-agent): preserve accounting and metadata across deferred updates Keep durable child-usage aggregates separate from pending sibling usage. Retry optional topology metadata after transient reads. Completes #2050 and #2051 integration. * fix: preserve session accounting and read-only persistence boundaries --------- Co-authored-by: Seth <seth@primeintellect.ai>
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
Total src: +20/−5 (net +15); tests: +50/−0 (net +50).
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
Touches kernel lifecycle memoization and MCP tool metadata; behavior changes on post-crash recovery and tool listing, but scope is narrow with targeted tests.
Overview
Fixes two runtime bugs where sessions could get stuck on a dead Python kernel and skill-MCP tools could advertise empty parameter schemas.
Dead kernel memo:
IpythonKernelProvisioner.ensure()now clears its cached manager whenstartedManager.isDefunctis true (newKernelClient/ReplKernelManagerflag for terminalshutdown). The next Python call goes through the normal startup path—including snapshot restore—instead of reusing a process that died after a successful boot. Managers that are merely not running but still repairing stay memoized so a second kernel does not race on the snapshot dir.MCP tool schemas:
McpIntegration._ensure_toolsinmcp_base.pyresolves tool parameters viainput_schemafirst, theninputSchema, matchingmcp.pyand restoring realinputSchemametadata under mcp>=2 instead of always{}.Reviewed by Cursor Bugbot for commit 749e216. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix dead kernel restart on
ensure()and readinput_schemafor mcp>=2 toolsReplKernelManager.isDefunctand the requiredKernelClient.isDefunctproperty so callers can detect a terminal-shutdown kernel.IpythonKernelProvisioner.ensure()now drops the memoized manager and its startup promise when defunct, forcing a fresh kernel on the next call; non-defunct managers stay memoized.McpIntegration._ensure_toolsto readinput_schemafirst and fall back toinputSchemafor older MCP objects, keeping only dictionary schemas and substituting empty schemas otherwise.KernelClientimplementers must now provide the read-onlyisDefunctproperty; any out-of-tree implementation missing it will fail the interface contract.Macroscope summarized 749e216.