{"record":{"id":"8c5c822e33a8543e","repo":"vercel/ai","slug":"harnessagent-onsandboxsession-is-deprecated-us","errorCode":null,"errorMessage":"HarnessAgent: `onSandboxSession` is deprecated. Use `sandboxConfig.onSession` instead.","messagePattern":"HarnessAgent: `onSandboxSession` is deprecated\\. Use `sandboxConfig\\.onSession` instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/harness/src/agent/harness-agent.ts","lineNumber":1157,"sourceCode":"\n  get request() {\n    return this.finalStep.request;\n  }\n\n  get response() {\n    return this.finalStep.response;\n  }\n\n  get providerMetadata() {\n    return this.finalStep.providerMetadata;\n  }\n}\n\nfunction resolveSandboxConfig(\n  settings: Pick<HarnessAgentSettings, 'sandboxConfig' | 'onSandboxSession'>,\n): HarnessAgentSandboxConfig {\n  if (settings.onSandboxSession != null) {\n    console.warn(\n      'HarnessAgent: `onSandboxSession` is deprecated. Use `sandboxConfig.onSession` instead.',\n    );\n  }\n\n  return {\n    ...settings.sandboxConfig,\n    ...(settings.sandboxConfig?.onSession == null &&\n    settings.onSandboxSession != null\n      ? { onSession: settings.onSandboxSession }\n      : {}),\n  };\n}\n\nasync function cleanupAfterStartFailure(input: {\n  sandboxSession: HarnessV1NetworkSandboxSession | SandboxSession;\n  ownsSandboxLifecycle: boolean;\n}): Promise<void> {\n  if (!input.ownsSandboxLifecycle) return;","sourceCodeStart":1139,"sourceCodeEnd":1175,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness/src/agent/harness-agent.ts#L1139-L1175","documentation":"HarnessAgent prints a deprecation warning when `onSandboxSession` is set in settings: that option has moved to `sandboxConfig.onSession`. The warning is emitted by resolveSandboxConfig while still honoring the old option (spreading it into the resolved config).","triggerScenarios":"Constructing/configuring HarnessAgent with a top-level `onSandboxSession` callback in HarnessAgentSettings; the code warns and maps it into sandboxConfig.","commonSituations":"Upgrading across harness versions where the sandbox callback moved; copied older example code; TypeScript may still accept the deprecated field during the migration window.","solutions":["Move the callback into settings.sandboxConfig.onSession","Remove the top-level onSandboxSession property","Silence the warning by completing the migration before the option is removed"],"exampleFix":"// before\nnew HarnessAgent({ onSandboxSession: session => {...} });\n// after\nnew HarnessAgent({\n  sandboxConfig: { onSession: session => {...} },\n});","handlingStrategy":"validation","validationCode":"if ('onSandboxSession' in settings) {\n  console.warn('onSandboxSession is deprecated; use sandboxConfig.onSession');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run codemods/migrations on upgrade to move deprecated options automatically","Use TypeScript exhaustiveness against the current HarnessAgentSettings type","Grep codebases for onSandboxSession when bumping the harness package"],"tags":["deprecation","sandbox","harness","migration"],"backgroundTag":"deprecated-option","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}