{"record":{"id":"d17f176d1820ad26","repo":"windmill-labs/windmill","slug":"this-type-draft-path-was-started-from-an-o","errorCode":null,"errorMessage":"This ${type} draft \"${path}\" was started from an older deployed version (forked from ${base}, latest is ${head}). Deploying now would overwrite the version deployed since. Call rebase_draft to discard the stale draft and get your changes back as a diff, then re-apply them (the new draft re-bases onto the latest version) and deploy. To deploy as-is and replace the newer version, call deploy_workspace_item again with force: true.","messagePattern":"This (.+?) draft \"(.+?)\" was started from an older deployed version \\(forked from (.+?), latest is (.+?)\\)\\. Deploying now would overwrite the version deployed since\\. Call rebase_draft to discard the stale draft and get your changes back as a diff, then re-apply them \\(the new draft re-bases onto the latest version\\) and deploy\\. To deploy as-is and replace the newer version, call deploy_workspace_item again with force: true\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/global/core.ts","lineNumber":6194,"sourceCode":"\t\t\ttriggerKind\n\t\t},\n\t\tnull,\n\t\t2\n\t)\n}\n\n// A draft started from an older deploy would silently overwrite whatever was\n// deployed since. Block the deploy and point the model at rebase_draft, unless it\n// explicitly forces the overwrite. `base`/`head` undefined ⇒ can't tell ⇒ allow.\nfunction assertDraftBasedOnLatest(\n\ttype: WorkspaceItemType,\n\tpath: string,\n\tbase: string | number | undefined,\n\thead: string | number | undefined,\n\tforce: boolean | undefined\n): void {\n\tif (force || base == null || head == null || base === head) return\n\tthrow new Error(\n\t\t`This ${type} draft \"${path}\" was started from an older deployed version (forked from ${base}, ` +\n\t\t\t`latest is ${head}). Deploying now would overwrite the version deployed since. Call rebase_draft to ` +\n\t\t\t`discard the stale draft and get your changes back as a diff, then re-apply them (the new draft ` +\n\t\t\t`re-bases onto the latest version) and deploy. To deploy as-is and replace the newer version, call ` +\n\t\t\t`deploy_workspace_item again with force: true.`\n\t)\n}\n\n// Discard a stale draft and return its own changes (vs the fork base) as a diff so\n// the model can re-apply them on the latest deploy. Discarding rather than resetting\n// keeps the base pointer honest (the next write re-bases on the current head) and\n// fails safe: a premature deploy hits \"no draft\" instead of silently shipping the\n// latest unchanged.\nasync function rebaseDraft(\n\targs: { type: WorkspaceItemType; path: string },\n\tctx: WriteDraftCtx\n): Promise<string> {\n\tswitch (args.type) {","sourceCodeStart":6176,"sourceCodeEnd":6212,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/global/core.ts#L6176-L6212","documentation":"The deploy_workspace_item tool detects that the chat's draft was forked from deployed version `base` while the item's latest deployed version is now `head` (base !== head). Deploying would silently clobber the newer deployment, so it throws with recovery guidance: rebase the draft, or pass force: true to overwrite deliberately.","triggerScenarios":"Someone (or another chat/CLI deploy) deployed a newer version of the same script/flow/app/trigger after this chat's draft was created, and the chat then calls deploy_workspace_item without force.","commonSituations":"Parallel editing via UI and AI chat; a teammate deployed while the agent worked; re-running an old chat session whose draft predates recent deployments.","solutions":["Call rebase_draft to discard the stale draft and receive the changes as a diff, re-apply them onto the latest version, then deploy","If overwriting the newer deployment is intentional, re-call deploy_workspace_item with force: true","Coordinate with whoever deployed the newer version before choosing force"],"exampleFix":"// before\ndeploy_workspace_item({ type: 'script', path: 'u/admin/cleanup' })\n// after — option 1 (safe)\nrebase_draft({ type: 'script', path: 'u/admin/cleanup' }) // then re-apply changes and deploy\n// after — option 2 (overwrite intentionally)\ndeploy_workspace_item({ type: 'script', path: 'u/admin/cleanup', force: true })","handlingStrategy":"validation","validationCode":"const deployed = await getDeployedVersion(type, path)\nif (draft.baseVersion !== deployed.version) {\n  // draft is stale: prefer rebase_draft over deploying\n}","typeGuard":null,"tryCatchPattern":"try {\n  await deployWorkspaceItem(args)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('older deployed version')) {\n    await rebaseDraft(args) // then re-apply changes and deploy\n    // or intentionally: await deployWorkspaceItem({ ...args, force: true })\n  }\n}","preventionTips":["Check the deployed version against the draft's base before every deploy in shared environments","Prefer rebase_draft when unsure — force overwrites teammates' work silently","Re-run deployments promptly after edits to shrink the stale-draft window"],"tags":["ai-agent","conflict","stale-draft","draft-management"],"backgroundTag":"stale-version-conflict","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}