{"record":{"id":"8ee65692400b70ef","repo":"deepseek-ai/deepseek-harness","slug":"dynamic-tool-registration-must-use-a-tool-returned","errorCode":null,"errorMessage":"dynamic tool registration must use a tool returned by harness.defineTool(...)","messagePattern":"dynamic tool registration must use a tool returned by harness\\.defineTool\\(\\.\\.\\.\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/extensions/cordis-host-runner/src/guard.ts","lineNumber":497,"sourceCode":"        assertSchemaKeys(value, path, ['type', ...requiredKey, ...ANNOTATION_KEYS])\n        break\n      /* v8 ignore next 2 -- SCHEMA_TYPES narrows this closed switch before dispatch. */\n      default:\n        throw new Error(`harness.defineTool ${path} must declare a valid type: ${VALID_TYPES}`)\n    }\n  }\n  /* v8 ignore next -- the root map task assigns before scheduling descendants. */\n  return holder.value ?? {}\n}\n\nfunction markDynamicTool(tool: ToolDefinition): DynamicToolDefinition {\n  Object.defineProperty(tool, DYNAMIC_TOOL, { value: true })\n  return tool as DynamicToolDefinition\n}\n\nfunction assertDynamicTool(tool: unknown): asserts tool is DynamicToolDefinition {\n  if (!isPlainRecord(tool) || (tool as DynamicToolMarker)[DYNAMIC_TOOL] !== true) {\n    throw new Error('dynamic tool registration must use a tool returned by harness.defineTool(...)')\n  }\n}\n\n/**\n * Structurally a content block, checked AFTER the JSON round-trip: a plain\n * object carrying a string `type` tag. Deliberately nothing deeper — the\n * ContentBlock union is merge-extensible (an unknown tag must pass), and every\n * downstream consumer dispatches on `type` and falls through unknowns.\n */\nfunction isContentBlockShape(value: unknown): boolean {\n  return isPlainRecord(value) && typeof value.type === 'string'\n}\n\n/**\n * How much of an invalid execute return the teaching error echoes back — a\n * huge blob would burn the model turn the error is trying to save.\n */\nconst RETURN_PREVIEW_LIMIT = 120","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/extensions/cordis-host-runner/src/guard.ts#L479-L515","documentation":"Error \"dynamic tool registration must use a tool returned by harness.defineTool(...)\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/extensions/cordis-host-runner/src/guard.ts:497 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"}