{"record":{"id":"5d116db3be0c4991","repo":"can1357/oh-my-pi","slug":"conflict-id-not-found-conflict-ids-are-regist-5d116d","errorCode":null,"errorMessage":"Conflict #${id} not found. Conflict ids are registered when `read` surfaces a marker block; re-read the file to get a current id.","messagePattern":"Conflict #(.+?) not found\\. Conflict ids are registered when `read` surfaces a marker block; re-read the file to get a current id\\.","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/write.ts","lineNumber":918,"sourceCode":"\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: resultText }],\n\t\t\tdetails: { resolvedPath: absolutePath },\n\t\t};\n\t}\n\n\t/**\n\t * Look up a single conflict entry by id and dispatch to {@link #resolveConflict}.\n\t * Throws a clear `not found` error when the id has been invalidated.\n\t */\n\tasync #resolveSingleConflictById(\n\t\tid: number,\n\t\treplacementContent: string,\n\t\tstripped: boolean,\n\t\tsignal: AbortSignal | undefined,\n\t): Promise<AgentToolResult<WriteToolDetails>> {\n\t\tconst entry = getConflictHistory(this.session).get(id);\n\t\tif (!entry) {\n\t\t\tthrow new ToolError(\n\t\t\t\t`Conflict #${id} not found. Conflict ids are registered when \\`read\\` surfaces a marker block; re-read the file to get a current id.`,\n\t\t\t);\n\t\t}\n\t\treturn this.#resolveConflict(entry, replacementContent, stripped, signal);\n\t}\n\n\t/**\n\t * Bulk-resolve every registered conflict via `conflict://*`.\n\t *\n\t * Entries are grouped by file and applied bottom-up by recorded start\n\t * line so each splice keeps later anchors valid. `content` tokens are\n\t * expanded *per entry*, so `content: \"@ours\"` keeps each block's own\n\t * ours side rather than collapsing every conflict to the first\n\t * block's ours.\n\t *\n\t * All-or-nothing semantics within a file: if any splice for a file\n\t * fails (stale anchors, missing base for `@base`, etc.), that file is\n\t * left untouched and the error is surfaced. Files that succeed are","sourceCodeStart":900,"sourceCodeEnd":936,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/write.ts#L900-L936","documentation":"Conflict ids are registered only when the `read` tool surfaces a conflict marker block, stored in the session's conflict history. Looking up an id that was never registered (or has been cleared) throws this ToolError telling the caller to re-read the file to obtain a current id.","triggerScenarios":"Calling write with conflict://<id> where the id is wrong, was from a previous session, references a conflict that was already resolved and evicted, or the file was never re-read after new conflicts appeared.","commonSituations":"Agent hallucinating an id, reusing ids after session restart, stale ids cached in agent notes after another resolution pass consumed them, ids referencing files not read with the conflict-surfacing read path.","solutions":["Re-read the file containing the conflict markers to get fresh, currently valid ids.","List currently registered conflicts (the conflict://* flow reports registered ids in related errors).","Use conflict://* with per-id directives once you know the valid ids.","Don't persist conflict ids across sessions — they are session-scoped."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// keep a local set of ids obtained from the most recent conflict-surfacing read\nconst knownIds = new Set([1, 2, 5]);\nif (!knownIds.has(id)) throw new Error(`#${id} is not a registered conflict id`);","typeGuard":"function isRegisteredConflictId(id: number, entries: { id: number }[]): boolean {\n  return entries.some(e => e.id === id);\n}","tryCatchPattern":"try {\n  await write(`conflict://${id}`, replacement);\n} catch (err) {\n  if (String(err.message).includes(\"not found\")) {\n    // re-read the file to refresh conflict ids, then retry\n  }\n  throw err;\n}","preventionTips":["Only use ids emitted by the latest read of the conflicted file.","Never reuse ids across sessions or after other resolutions.","Re-read before each conflict resolution pass."],"tags":["conflict-resolution","invalid-id","stale-state"],"backgroundTag":"unknown-resource-id","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}