{"record":{"id":"0da5d93d25658b6d","repo":"vercel/ai","slug":"deep-agents-reasoning-requires-chatanthropic","errorCode":null,"errorMessage":"Deep Agents reasoning requires ChatAnthropic","messagePattern":"Deep Agents reasoning requires ChatAnthropic","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/harness-deepagents/src/bridge/index.ts","lineNumber":116,"sourceCode":"        const configuredModel = buildModel({\n          rawModel: activeModel,\n          thinking: activeThinking,\n          effort: activeEffort,\n        });\n        if (!configuredModel) throw new Error('Deep Agents model is missing');\n        return handler({ ...request, model: configuredModel });\n      }\n\n      let model = request.model;\n      if (\n        '_getModelInstance' in model &&\n        typeof model._getModelInstance === 'function'\n      ) {\n        model = await model._getModelInstance();\n      }\n\n      if (!(model instanceof ChatAnthropic)) {\n        throw new Error('Deep Agents reasoning requires ChatAnthropic');\n      }\n\n      const configuredModel = buildModel({\n        rawModel: model.model,\n        thinking: activeThinking,\n        effort: activeEffort,\n      });\n      if (!configuredModel) throw new Error('Deep Agents model is missing');\n\n      return handler({ ...request, model: configuredModel });\n    },\n  });\n}\n\nconst args = parseArgs(argv.slice(2));\nconst workdir = args.workdir;\nconst bridgeStateDir = args.bridgeStateDir;\nif (!workdir || !bridgeStateDir) {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-deepagents/src/bridge/index.ts#L98-L134","documentation":"The deepagents bridge's model middleware only supports Anthropic models. When a turn carries thinking/effort settings (but no explicit model string), the bridge resolves the request's model and requires it to be a LangChain `ChatAnthropic` instance; anything else (e.g. an OpenAI or other LangChain chat model) is rejected. Deep Agents reasoning here is wired exclusively through the Anthropic client, so other providers cannot be used for reasoning.","triggerScenarios":"Calling a harness turn with `thinking` or `effort` set while the resolved request model is not a `ChatAnthropic` instance (e.g. `ChatOpenAI`, or a lazy model whose `_getModelInstance()` yields a non-Anthropic client).","commonSituations":"Configuring the harness/agent with a non-Anthropic LangChain chat model while enabling extended thinking or effort; switching providers after the model middleware was added; passing a wrapped model object that delegates to a non-Anthropic client.","solutions":["Use a `ChatAnthropic` model (from `@langchain/anthropic`) for the Deep Agents agent when thinking/effort is enabled.","Set the model explicitly via the harness `model` option (a model slug string) so the bridge builds a `ChatAnthropic` itself via `buildModel`.","Remove `thinking`/`effort` from the request if you must use a non-Anthropic model, so the middleware passes through without the instanceof check.","Point `ANTHROPIC_BASE_URL` at a gateway if you need a non-Anthropic backend behind an Anthropic-compatible API."],"exampleFix":"// before\nnew ChatOpenAI({ model: 'gpt-4o' }) // with thinking enabled\n// after\nimport { ChatAnthropic } from '@langchain/anthropic';\nnew ChatAnthropic({ model: 'claude-sonnet-4-5', thinking: { type: 'enabled', budget_tokens: 1024 } })","handlingStrategy":"validation","validationCode":"import { ChatAnthropic } from '@langchain/anthropic';\nif (thinkingEnabled && !(resolvedModel instanceof ChatAnthropic)) {\n  throw new Error('Deep Agents reasoning requires ChatAnthropic');\n}","typeGuard":"function isChatAnthropic(m: unknown): m is ChatAnthropic {\n  return m instanceof ChatAnthropic;\n}","tryCatchPattern":"try {\n  await runTurn(start);\n} catch (error) {\n  if (error instanceof Error && error.message.includes('requires ChatAnthropic')) {\n    // switch model to ChatAnthropic or drop thinking/effort and retry\n  }\n  throw error;\n}","preventionTips":["Always use ChatAnthropic models with the deepagents harness","Only enable thinking/effort with Anthropic models","Pin the model via the harness `model` string option so the bridge constructs ChatAnthropic itself"],"tags":["provider-unsupported","model-config","anthropic"],"backgroundTag":"unsupported-model-provider","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}