{"record":{"id":"59e1af9ae4f7cad0","repo":"coleam00/Archon","slug":"model-binding-bindingname-has-invalid-thinkin","errorCode":null,"errorMessage":"Model binding '${bindingName}' has invalid thinking options.","messagePattern":"Model binding '(.+?)' has invalid thinking options\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/workflows/src/model-validation.ts","lineNumber":501,"sourceCode":"      aliases: Object.fromEntries(\n        Object.entries(effective.aliases).map(([name, preset]) => [name, { ...preset }])\n      ),\n    },\n  };\n}\n\n/** Read metadata written by this module; malformed external JSON fails explicitly. */\nexport function readRunModelBindingsMetadata(\n  metadata: Record<string, unknown> | undefined\n): RunModelBindingsMetadata | undefined {\n  const value = metadata?.[RUN_MODEL_BINDINGS_METADATA_KEY];\n  if (value === undefined) return undefined;\n  const parsed = runModelBindingsMetadataSchema.safeParse(value);\n  if (!parsed.success) {\n    const path = parsed.error.issues[0]?.path ?? [];\n    const bindingName = typeof path[2] === 'string' ? path[2] : 'unknown';\n    if (path.includes('thinking')) {\n      throw new Error(`Model binding '${bindingName}' has invalid thinking options.`);\n    }\n    if (path.includes('effort')) {\n      throw new Error(`Model binding '${bindingName}' has an invalid effort.`);\n    }\n    if (path[0] === 'overrides' && (path[1] === 'tiers' || path[1] === 'aliases')) {\n      throw new Error(`Workflow run has invalid model_bindings ${path[1]} metadata.`);\n    }\n    if (path[0] === 'effective') {\n      throw new Error('Workflow run has invalid effective model bindings.');\n    }\n    throw new Error('Workflow run has invalid model_bindings metadata.');\n  }\n\n  const tiers = Object.fromEntries(\n    Object.entries(parsed.data.overrides.tiers ?? {}).map(([name, preset]) => [\n      name,\n      normalizePersistedOverridePreset(name, preset),\n    ])","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/workflows/src/model-validation.ts#L483-L519","documentation":"readRunModelBindingsMetadata validates a run's persisted model_bindings metadata against runModelBindingsMetadataSchema. When the schema rejects a binding's 'thinking' options, the function throws this error naming the offending binding, because invalid thinking configuration cannot be silently ignored at execution time.","triggerScenarios":"executeWorkflow loads a run whose model_bindings metadata contains a binding entry whose thinking field fails safeParse — e.g. thinking options of the wrong shape/type written by an older or buggy writer, or hand-edited metadata.","commonSituations":"Hand-editing or backfilling run metadata in the database; older binary writing a thinking shape the current schema no longer accepts; copying run rows between environments with different schema versions.","solutions":["Inspect the run's model_bindings metadata and fix or remove the binding's thinking options to match runModelBindingsMetadataSchema","Re-create the run with valid model_bindings instead of reusing the corrupted metadata row","If a schema change caused it, migrate the persisted metadata to the new shape (additively) before running"],"exampleFix":"// before (metadata)\n\"bindings\": { \"node1\": { \"thinking\": \"yes\" } }\n// after\n\"bindings\": { \"node1\": { \"thinking\": { \"type\": \"enabled\", \"budgetTokens\": 2048 } } }","handlingStrategy":"validation","validationCode":"import { runModelBindingsMetadataSchema } from '@archon/workflows';\nconst parsed = runModelBindingsMetadataSchema.safeParse(metadata);\nif (!parsed.success) {\n  const bad = parsed.error.issues.find(i => i.path.includes('thinking'));\n  if (bad) throw new Error(`Binding '${String(bad.path[2])}' has invalid thinking options: ${bad.message}`);\n}","typeGuard":"function hasValidThinkingOptions(b: unknown): b is { thinking?: { type: string; budgetTokens?: number } } {\n  return runModelBindingsMetadataSchema.shape.bindings\n    .element.pick({ thinking: true }).safeParse(b).success;\n}","tryCatchPattern":"try {\n  await executeWorkflow(runId);\n} catch (err) {\n  if (err instanceof Error && /has invalid thinking options/.test(err.message)) {\n    console.error(`Run ${runId} metadata corrupt: ${err.message}. Re-create or repair model_bindings.`);\n  } else throw err;\n}","preventionTips":["Never hand-edit persisted model_bindings metadata; change it through the API/engine","Validate metadata with runModelBindingsMetadataSchema right after writing it in any custom writer","Keep writer and reader binaries on compatible schema versions when resuming runs"],"tags":["validation","metadata","thinking-options"],"backgroundTag":"schema-validation-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}