Repository navigation
Description
Labels requested: bug, needs-triage, cli
Product or interface
Source build or repository tooling — the Python SDK minimax-code-sdk (0.1.1 on PyPI) that starts, cancels and reaps the mcode CLI on the host.
Version
- Source:
main@3c21163(repository version0.7.2), tagv0.7.2=c6c7f28 - SDK package:
minimax-code-sdk0.1.1 (PyPI, published 2026-11-17), source tagcode-sdk-python-v0.1.1 - Python 3.12.10 (Windows) / 3.11.2 (Linux), Node.js v24.18.0 (Windows) / v20.20.2 (Linux), pnpm 9.15.0
Platform
Windows
OS version and architecture
Windows 11 x64 (build 26200)
Issue area
Build / CI / source distribution
What happens
The Windows leg of the Python SDK workflow is green, but it never starts a CLI process. The whole fake-CLI test suite is skipped on Windows, so the process layer of the SDK — spawn, stream, cancel, timeout, reap — has never run on the platform where it behaves differently. Two consequences:
1. The Windows CI line proves nothing about the SDK's process handling.
packages/code-sdk-python/tests/conftest.py:14 skips every test that uses the fake_env fixture:
if sys.platform == "win32":
pytest.skip("the fake CLI is a POSIX script; Windows runs the resolver and option tests")That is 25 test cases in packages/code-sdk-python/tests/test_sdk.py (22 of its 27 test functions). The whole suite reports 34 passed, 30 skipped on Windows, and the 3 remaining skips are the opt-in end-to-end tests. The other Windows coverage is the launcher resolution (tests/test_cli.py) and the release checks (tests/test_release_check.py); neither starts a process. The workflow comment says the same ( .github/workflows/python-sdk.yml:28: "fake-CLI process tests are POSIX-only").
2. A cancelled Turn is reported as a failed run on Windows, and as a cancellation on Linux and macOS.
This is the part the skipped suite hides. packages/code-sdk-python/src/minimax_code/thread.py:244 stops the CLI with a hard kill on Windows, because Windows has no signals between processes:
if sys.platform == "win32":
self.proc.terminate() # TerminateProcess -> exit code 1
else:
self.proc.send_signal(signal.SIGTERM) # exit code -15packages/code-sdk-python/src/minimax_code/errors.py:129 maps that exit code to an error, and the mapping only knows the cancellation exit codes 130 and "negative means killed by a signal" (errors.py:155). On Windows the exit code is 1, so the run is reported as an internal failure:
| Linux / macOS | Windows | |
|---|---|---|
| CLI stopped with | SIGTERM (exit -15) |
TerminateProcess (exit 1) |
| SDK raises | MCodeAbortError: The MCode run was cancelled. |
MCodeRunError: The MCode run ended without a result: exit code 1 (status="failed", category="internal") |
The TypeScript SDK, which the Python SDK states it mirrors (packages/code-sdk-python/src/minimax_code/thread.py:1), handles this case explicitly — packages/code-sdk/src/exec-process.ts:323:
if (this.abortRequested && code !== 2) {
this.fail(new MCodeAbortError('The MCode run was cancelled.', details));
return;
}The Python SDK has no equivalent of abortRequested, so on Windows the cancellation is indistinguishable from a CLI crash. MCodeAbortError is a documented error type of the package (packages/code-sdk-python/README.md:127) and is what a user gets for the same action on Linux and macOS.
Steps to reproduce
-
Run the Python SDK test suite on a Windows host and read the skip reasons:
python -m pytest packages/code-sdk-python/tests -q -rs
SKIPPED [1] tests/test_sdk.py:39: the fake CLI is a POSIX script; Windows runs the resolver and option tests ... (25 test cases) 34 passed, 30 skipped -
Reproduce the divergence. Save this as
repro_cancel.pyin the repository root and runpython repro_cancel.py(needs Node.js, themcodeCLI is a Node program anyway):import asyncio import os import pathlib import sys sys.path.insert(0, "packages/code-sdk-python/src") from minimax_code import MCode, MCodeError, MCodeOptions FAKE = pathlib.Path("fake-mcode.js") FAKE.write_text( "if (process.argv[2] === '--version') { console.log('0.7.2'); process.exit(0); }\n" "process.stdout.write(JSON.stringify({schemaVersion: 1, type: 'exec.started'," " sequence: 1, timestampMs: 0, runId: 'r', sessionId: 's', turnId: 't'}) + '\\n');\n" "setInterval(() => {}, 1000);\n", encoding="utf-8", ) async def main() -> None: client = MCode(MCodeOptions(bin=str(FAKE.resolve()), env=dict(os.environ))) streamed = await client.start_thread().run_streamed("hi") try: async for event in streamed: if event["type"] == "exec.started": streamed.cancel() except MCodeError as error: print(f"{type(error).__name__}: {error}") print(f" status={getattr(error, 'status', None)!r} exit_code={error.exit_code!r}") finally: FAKE.unlink() asyncio.run(main())
The same script and the same SDK code on Linux and on Windows:
# Linux (Debian 12, Python 3.11.2, Node v20.20.2) MCodeAbortError: The MCode run was cancelled. status=None exit_code=-15 # Windows 11 x64 (build 26200), Python 3.12.10, Node v24.18.0 MCodeRunError: The MCode run ended without a result: exit code 1 status='failed' exit_code=1
Expected and actual behavior
- Expected: a cancelled Turn raises
MCodeAbortErroron every platform, as the TypeScript SDK does and as the README documents. The Windows CI leg exercises the SDK's process layer. - Actual: on Windows the cancellation raises
MCodeRunErrorwithstatus="failed"andcategory="internal", and no CI job ever starts a CLI process on Windows, so the difference was never observed.
Two more details of the same root cause, both inside the skipped suite:
-
os.kill(pid, signal.SIGINT)terminates the process on Windows with exit code2instead of raisingSIGINTin it, andos.kill(pid, signal.SIGTERM)terminates it with exit code15. Neither runs the child's signal handler. Measured on Windows 11:call exit code handler ran os.kill(pid, SIGINT)2no os.kill(pid, SIGTERM)15no proc.terminate()1no proc.kill()1no tests/test_sdk.py:303relies on the SIGINT delivery, so it cannot hold on Windows; the same is true for thepkill -INThelper attests/test_sdk.py:167. -
The timeout backstop kills the CLI with a signal number on POSIX and with exit code
1on Windows, so the assertionexit_code < 0attests/test_sdk.py:214cannot hold there either.
Redacted error summary
MCodeRunError: The MCode run ended without a result: exit code 1
status='failed' exit_code=1
What I prepared
A branch that runs the fake-CLI suite on Windows. It is pushed on my fork as test/python-sdk-windows-coverage (commit 65f2ff3, one commit on top of 3c21163). I cannot open a pull request myself — the API refuses cross-repository pull requests for my account — so the branch is the handover.
- new:
packages/code-sdk-python/tests/fake_mcode.mjs— a Node port oftests/fake_mcode.py, scenario by scenario. Windows cannot execute a shebang script (CreateProcessrejects it with WinError 193), and the SDK only starts.exe,.comand.jsentries there (packages/code-sdk-python/src/minimax_code/_cli.py:82), so the fake CLI needs an entry the SDK can launch. A.mjsentry is started asnode <entry>. packages/code-sdk-python/tests/conftest.py— thefake_envfixture picks the platform's fake CLI instead of skipping the suite.packages/code-sdk-python/tests/test_sdk.py— the three POSIX-specific expectations become platform aware; the two tests that need a signal delivered to another process stay POSIX-only, with a reason..github/workflows/python-sdk.yml— the Windows leg gets Node.js, and the comment about POSIX-only tests is corrected.release/public-source.json— regenerated for the new file.
Result on Windows 11 x64, CPython 3.12.10, pytest -W error with PYTHONWARNDEFAULTENCODING=1:
59 passed, 5 skipped in 8.02s # was: 34 passed, 30 skipped
ruff check, ruff format --check and mypy are clean. The 5 remaining skips are the 3 opt-in end-to-end tests and the 2 tests that need POSIX signal delivery.
The branch contains no production-code change: it only measures and pins the current Windows behaviour. The error-class divergence above is a separate question — mirroring packages/code-sdk/src/exec-process.ts:323 in _Exec/error_for_exit would make a cancelled Turn raise MCodeAbortError on Windows as well. I did not include that in the branch because it changes the semantics of a published package.
Before submitting
- I have searched existing issues.
- I have included my version and removed sensitive information.
Activity