{"record":{"id":"53568f2ecd0284e0","repo":"deepseek-ai/deepseek-harness","slug":"harness-definetool-output-must-declare-schema-r","errorCode":null,"errorMessage":"harness.defineTool output must declare { schema, render, presentationMeta? }","messagePattern":"harness\\.defineTool output must declare (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/extensions/cordis-host-runner/src/guard.ts","lineNumber":555,"sourceCode":"    `output.render returned ${describeReturn(value)} — it must return an ARRAY of content blocks:\\n`\n    + '  ✓ return [{ type: \\'text\\', text: String(value) }]',\n  )\n}\n\n/**\n * The `harness.defineTool` handed into the sandbox: the real DSL, with `parameters` normalized\n * into a fresh host-realm ParameterSchemaSpec (raw object wrappers unwrapped,\n * required arrays mapped, and explicit DSL object openness enforced) and the tool's `execute` return normalized into the host realm\n * via a JSON round-trip. Non-JSON or wrong-shape output fails that call instead of poisoning\n * the session log.\n * @param options - the standard `defineTool` options; `parameters` may be the ParameterSchemaSpec DSL or a JSON-Schema-style wrapper.\n * @returns the marker-tagged definition `harness.registerTool` (and the guarded `ctx.tools.register`) accepts.\n */\nexport function sandboxDefineTool(options: unknown): ToolDefinition {\n  if (!isPlainRecord(options)) throw new Error('harness.defineTool options must be an object')\n  const normalized = normalizeParameterSchemaSpec(options.parameters)\n  if (!isPlainRecord(options.output)) {\n    throw new Error('harness.defineTool output must declare { schema, render, presentationMeta? }')\n  }\n  const output = options.output\n  if (typeof output.render !== 'function') throw new Error('harness.defineTool output.render must be a function')\n  if (output.presentationMeta !== undefined && typeof output.presentationMeta !== 'function') {\n    throw new Error('harness.defineTool output.presentationMeta must be a function when present')\n  }\n  if (typeof options.execute !== 'function') throw new Error('harness.defineTool execute must be a function')\n  const schema = cloneJson(output.schema, 'harness.defineTool output.schema')\n  const rawExecute = options.execute as (args: unknown, exec: unknown) => Promise<unknown>\n  const rawRender = output.render as (args: unknown, value: unknown) => unknown\n  const rawPresentationMeta = output.presentationMeta as ((args: unknown, value: unknown) => unknown) | undefined\n  const erasedDefineTool = defineTool as unknown as (definition: unknown) => ToolDefinition\n  const tool = erasedDefineTool({\n    ...options,\n    parameters: normalized.spec,\n    output: {\n      schema,\n      render(args: unknown, value: unknown): ContentBlock[] {","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/extensions/cordis-host-runner/src/guard.ts#L537-L573","documentation":"Error \"harness.defineTool output must declare { schema, render, presentationMeta? }\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/extensions/cordis-host-runner/src/guard.ts:555 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"}