Merged via /merge-batch (2026-10-18). The opt-in ZCode image-runtime helper gains the hash-guarded numeric-provider-code-v1 step: code-based business-error detection requires a numeric provider code, so GLM tool-call text in the finish record no longer kills valid long turns (the intermittent 502). Explicit failure markers still fail as before.
Integration on top: merged release/v3.8.52 (after #16926 landed) — the three add/add conflicts resolved to this PR's version, which is exactly #16926's tip content plus this PR's commit; dropped the already-consumed #16926 changelog fragment and added one for this PR. Evidence: zcode executor/image-runtime/protocol/provider suites 27/27, changelog-integrity + docs-sync OK. Remaining CI reds are the inherited base-red #15306. Thanks @megamen32!
Moves the ZCode executor onto the native workspace/generateWorkspaceText model call. The caller's tools, image inputs (on vision-capable models) and usage are kept, and maxOutputTokens is bounded into the model's native option range on every turn. The author tested it live.
Maintainer fixes on top:
- Complexity ratchet: execute() in open-sse/executors/zcode.ts had reached complexity 31, cognitive 24 and 103 lines (ratchet 1->2 / 0->1). Split it into prepareZcodeRequest(), boundMaxOutputTokens(), errorText(), and the private waitForSelection() / workingDirectory(). Behaviour is unchanged and zcode.ts now has no ratchet violations at all.
- Added changelog.d/fixes/16926-zcode-native-model-tools.md.
- Kept scripts/ops/zcode-image-runtime.mjs after checking it is strictly opt-in. It runs only when invoked by hand with two explicit paths. No npm script, postinstall or runtime import references it. It refuses any build whose SHA-256 differs from the pinned one, writes the patched copy to a separate directory and never edits the installed ZCode runtime. docs/ops/ZCODE_IMAGES.md and the changelog fragment both document it as opt-in.
Evidence: zcode tests pass 22/22 (executor, image-runtime, protocol, provider, win32 spawn). typecheck:core, open-sse/api typecheck, file-size, complexity, cognitive, dead-code, boundary, skills-gen (Generated 0), changelog-integrity, env-doc-sync, docs-sync, fabricated-docs, eslint and prettier all exit 0. Any remaining CI reds come from the inherited base-red #15306.
Credit: the commits carry the author email megamen932@gmai.com, a typo; the author is @megamen32. Thanks @megamen32