{"record":{"id":"cd35110255554616","repo":"deepseek-ai/deepseek-harness","slug":"an-agent-factory-is-already-registered","errorCode":null,"errorMessage":"an agent factory is already registered","messagePattern":"an agent factory is already registered","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/agent/src/index.ts","lineNumber":374,"sourceCode":"  withoutInitiator<T>(operation: () => T): T {\n    return this.runWithInitiator(undefined, operation)\n  }\n\n  /**\n   * Register the agent-creation factory (the loop calls this on construction,\n   * effect-scoped). A traced Cordis service is canonicalized to its concrete\n   * target; each create/resume call is then traced through that caller's\n   * context so ownership follows the caller without stacking proxy layers.\n   * Throws if a factory is already registered. Returns the disposer; on\n   * dispose the factory slot is cleared.\n   * @param factory - the loop-owned factory {@link create}/{@link resume} delegate to.\n   * @returns the disposer that clears the factory slot. The exact\n   *   Cordis effect disposer (single-shot): composite (generator) effects may\n   *   yield it directly — exact identity nests the teardown in order.\n   */\n  setFactory(factory: AgentFactory): () => void {\n    const dispose = this.ctx.effect(() => {\n      if (this.factory !== undefined) throw new Error('an agent factory is already registered')\n      // Avoid stacking two Cordis shadow layers when a caller passes a Service\n      // already read through a context. Calls are re-traced through their\n      // actual owner context below.\n      const target = (factory as AgentFactory & { [symbols.original]?: AgentFactory })[symbols.original] ?? factory\n      this.factory = { target }\n      return () => { this.factory = undefined }\n    }, 'agents.setFactory()')\n    // The exact cordis effect disposer (the agents.register() convention): a\n    // caller's composite effect can yield it for in-order teardown; the\n    // loop's constructor effect returns it directly, identity-nesting the\n    // registration under that effect.\n    // oxlint-disable-next-line typescript/no-misused-promises -- synchronous cleanup; direct return preserves disposer identity\n    return dispose\n  }\n\n  /** Return the active creation factory. */\n  private requireFactory(): FactorySlot {\n    if (this.factory === undefined) throw new Error(NO_FACTORY_MESSAGE)","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/core/agent/src/index.ts#L356-L392","documentation":"Error \"an agent factory is already registered\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/core/agent/src/index.ts:374 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register only one agent factory."],"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"}