Skip to content

fix(exec): explain Session workspace mismatches instead of suggesting a retry - #584

Merged
hetaoBackend merged 1 commit into
mainfrom
fix/session-cwd-guidance
Nov 3, 2026
Merged

hetaoBackend merged 1 commit into
mainfrom
fix/session-cwd-guidance

Conversation

@1anZhang

@1anZhang 1anZhang commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Change

mcode exec appended "Retry after the connection recovers." to every runtime failure, including Session errors that can never succeed on retry. Resuming a Session from a different directory (for example through the Python SDK's resume_thread() without cwd) printed:

mcode exec failed: The run failed: Session workspace does not match --cwd: mvs_…. Retry after the connection recovers.

It now prints:

mcode exec failed: The run failed: Session mvs_… belongs to workspace /path/to/workspace, not --cwd /path/to/project; rerun with --cwd /path/to/workspace.
  • Workspace mismatch, archived Session and missing --continue target errors are marked retryable: false and say what to do next. Exit code (4) and category (runtime) are unchanged, so SDK error mapping is unaffected.

  • formatTuiExecFailure and formatTuiExecResultFailure omit the retry hint for non-retryable failures (TuiExecError.retryable === false / result.error.retryable === false); retryable or unspecified failures keep it.

  • Python SDK: the README (new "Resuming a Session" section, quick start) and the MCode.resume_thread / SyncMCode.resume_thread docstrings state that a resumed Session must use the cwd it was created with.

  • PR labels: bug, cli.

Validation

  • Checks run and results:
    • pnpm verify (full profile, darwin) on 04e800ae: passed, 17 gates. Skipped: test:windows (platform), test:release-package (needs an npm release archive).
    • New tests in packages/tui/test/unit/headless-runner.test.ts: workspace mismatch message and exit code without sending a message, archived and missing --continue messages without "Retry", and the retry hint kept only for retryable failed results.
    • Python SDK: ruff, ruff format, mypy (strict), pytest 37 passed / 3 skipped (opt-in e2e).
    • Manual: node dist/cli.js exec --session=<id> --cwd=<other dir> against a real local Session prints the new message with exit 4; the installed 0.7.1 CLI prints the old retry hint for the same input.
  • Performance: not applicable.
  • NOT RUN, platform limitations and live-service boundaries: Windows path display not exercised manually (comparison logic unchanged). No model call is involved in these error paths.

Publication and contribution checks

  • I have permission to contribute these changes under the existing licenses applicable to the changed files/packages; imported material and its provenance are identified and existing notices are preserved.
  • No credentials, account data, real user content, internal source history or private review material is included.
  • Added/removed source files were reviewed before regenerating release/public-source.json; new tests are declared in test/vitest-suites.json where applicable (no files added; tests extend an existing declared file).
  • Shared English/Chinese documentation and capability/verification records are updated where applicable. Mock/offline results are not described as live-service acceptance.

Maintainer handoff

Publication scope or license changes (if any): none.

Shared-source port: pending (packages/tui/src/headless/* is shared implementation).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

… a retry

mcode exec appended "Retry after the connection recovers." to every runtime
failure, including Session errors that can never succeed on retry. A resumed
Session whose workspace differs from --cwd now names the Session workspace and
the --cwd to use; archived Sessions and a missing --continue target also say
what to do next. These errors are marked non-retryable, keep exit code 4 and
category runtime, and failed results with retryable: false no longer get the
retry hint.

Document in the Python SDK README and resume_thread docstrings that a resumed
Session must use the cwd it was created with.
@1anZhang 1anZhang added bug Something isn't working cli Standalone mcode: TUI, headless, ACP and source builds/tooling labels Nov 3, 2026
@hetaoBackend
hetaoBackend merged commit 6e062ae into main Nov 3, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cli Standalone mcode: TUI, headless, ACP and source builds/tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants