{"record":{"id":"62ac8f40ebdddcfd","repo":"toeverything/AFFiNE","slug":"copilot-action-taken","errorCode":"copilot_action_taken","errorMessage":"Action has been taken, no more messages allowed.","messagePattern":"Action has been taken, no more messages allowed\\.","errorType":"exception","errorClass":"CopilotActionTaken","httpStatus":403,"severity":"error","filePath":"packages/backend/server/src/plugins/copilot/session.ts","lineNumber":107,"sourceCode":"    if (!this.stashTurnCount) return [];\n    return this.state.turns.slice(-this.stashTurnCount);\n  }\n\n  get latestUserTurn() {\n    return this.state.turns.findLast(({ role }) => role === 'user');\n  }\n\n  findTurn(turnId: string) {\n    return this.state.turns.find(({ id }) => id === turnId);\n  }\n\n  private appendTurn(turn: Turn, persisted: boolean) {\n    if (\n      this.state.prompt.action &&\n      this.state.turns.length > 0 &&\n      turn.role === 'user'\n    ) {\n      throw new CopilotActionTaken();\n    }\n    this.state.turns.push(turn);\n    if (!persisted) {\n      this.stashTurnCount += 1;\n    }\n  }\n\n  pushTurn(turn: Turn) {\n    this.appendTurn(turn, false);\n  }\n\n  pushPersistedTurn(turn: Turn) {\n    this.appendTurn(turn, true);\n  }\n\n  revertLatestMessage(removeLatestUserMessage: boolean) {\n    const turns = this.state.turns;\n    turns.splice(","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/copilot/session.ts#L89-L125","documentation":"appendTurn throws CopilotActionTaken when a user turn is appended to a session whose prompt is an action and prior turns already exist — action prompts allow exactly one user message, and further input is rejected.","triggerScenarios":"Thrown at packages/backend/server/src/plugins/copilot/session.ts:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Start a new copilot session to continue the conversation after an action has been taken.","Do not send further messages on a session that is finalized by an action; create a fresh session instead.","Adjust the client flow to open a new session after the action completes."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}