{"record":{"id":"aa43c1fe3d1fba33","repo":"deepseek-ai/deepseek-harness","slug":"dsh-tools-mode-mode-requires-a-code-runtime","errorCode":null,"errorMessage":"dsh-tools: mode \"${mode}\" requires a code runtime — load a ctx.codeRuntime implementation (e.g. @deepseek-ai/dsh-code-runtime-worker-thread) or set tools mode to \"native\"","messagePattern":"dsh-tools: mode \"(.+?)\" requires a code runtime — load a ctx\\.codeRuntime implementation \\(e\\.g\\. @deepseek-ai/dsh-code-runtime-worker-thread\\) or set tools mode to \"native\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/tools/src/index.ts","lineNumber":1022,"sourceCode":"   * Resolve the code runtime or throw the actionable misconfiguration error.\n   * Read at use time (assembly / run_code execution), NOT via static\n   * `inject`: an inject entry would hold `ctx.tools` — and every tool plugin\n   * behind it — hostage to a code runtime existing even under `mode:\n   * 'native'` (the loop's optional-backend idiom, same as\n   * `sessionPersistence`).\n   *\n   * Assembly and `run_code` execution read separately, so the language is not\n   * bound to a request. Harmless while one published backend exists — both\n   * reads return the same flavor — but a reload that swapped in a second\n   * language between them would hand a program written against one SDK to the\n   * other. Binding it is deferred until a second backend ships (the first\n   * point it is testable); rationale in the\n   * [language-dispatch note](../../../../.agents/notes/implemented/feature/2026-07-31-code-mode-language-dispatch.md).\n   */\n  private requireCodeRuntime(mode: ToolPresentationMode): CodeRuntime {\n    const runtime = this.ctx.get('codeRuntime')\n    if (!runtime) {\n      throw new Error(`dsh-tools: mode \"${mode}\" requires a code runtime — load a ctx.codeRuntime implementation (e.g. @deepseek-ai/dsh-code-runtime-worker-thread) or set tools mode to \"native\"`)\n    }\n    if (!Object.hasOwn(SDK_RENDERERS, runtime.language)) {\n      const known = Object.keys(SDK_RENDERERS).map(name => JSON.stringify(name)).join(', ')\n      throw new Error(`dsh-tools: no SDK renderer registered for runtime language ${JSON.stringify(runtime.language)} (known: ${known})`)\n    }\n    return runtime\n  }\n\n  /**\n   * Register globally or in the calling agent scope. Scoped tools shadow\n   * globals; duplicates within one layer and the reserved `run_code` name fail.\n   * @param definition - tool schema, execution, and optional finalization/presentation callbacks.\n   * @returns the exact disposer that unregisters the tool.\n   */\n  register(definition: ToolDefinition): () => void {\n    const name = definition.name\n    const output = (definition as Partial<ToolDefinition>).output\n    if (output === undefined || typeof output !== 'object'","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/core/tools/src/index.ts#L1004-L1040","documentation":"Error \"dsh-tools: mode \"${mode}\" requires a code runtime — load a ctx.codeRuntime implementation (e.g. @deepseek-ai/dsh-code-runtime-worker-thread) or set tools mode to \"native\"\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/core/tools/src/index.ts:1022 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}