{"record":{"id":"9737cc51ac26ae09","repo":"paperclipai/paperclip","slug":"approval-required","errorCode":"approval_required","errorMessage":"Tool action requires approval","messagePattern":"Tool action requires approval","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":409,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":1516,"sourceCode":"    if (!allowedActions || allowedActions.includes(action)) return;\n    await writeAudit({\n      session,\n      companyId: session.companyId,\n      agentId: session.agentId,\n      runId: session.runId,\n      issueId: session.issueId,\n      action: action.endsWith(\"/list\") ? \"tool_gateway.discovery\" : \"tool_gateway.call_denied\",\n      details: {\n        decision: \"deny\",\n        reasonCode: \"gateway_token_action_denied\",\n        requestedAction: action,\n        allowedActions,\n      },\n    });\n    throw new ToolGatewayHttpError(403, \"Gateway bearer token is not allowed to perform this MCP action\", \"gateway_token_action_denied\", {\n      requestedAction: action,\n    });\n  }\n\n  async function writeToolCallEvent(input: {\n    invocationId?: string | null;\n    actionRequestId?: string | null;\n    session: ToolGatewaySession;\n    eventType: \"policy_decision\" | \"invocation_created\" | \"approval_requested\" | \"approval_resolved\" | \"call_started\" | \"call_completed\" | \"call_failed\" | \"call_denied\";\n    outcome: \"pending\" | \"success\" | \"failure\" | \"denied\" | \"timeout\" | \"cancelled\";\n    toolName: string;\n    policyDecision?: \"allow\" | \"deny\" | \"require_approval\" | \"defer_runtime\" | null;\n    reasonCode?: string | null;\n    argumentsSummary?: ReturnType<typeof summarizeToolValue> | null;\n    resultSummary?: ReturnType<typeof summarizeToolValue> | null;\n    metadata?: Record<string, unknown> | null;\n    tool?: ToolGatewayDescriptor | null;\n  }) {\n    const metadata = input.tool ? toolAuditMetadata(input.tool) : {};\n    await db.insert(toolCallEvents).values({\n      companyId: input.session.companyId,","sourceCodeStart":1498,"sourceCodeEnd":1534,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L1498-L1534","documentation":"Approval-required flow: this helper builds the agent-facing instruction text returned with the 409/deferral when a governed tool call needs human approval. It resolves the issue identifier (falling back to the raw issueId) so the agent knows which task's approval card to wait on and to end its run in_review instead of retrying.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:1483 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request approval for the tool action (create an approval request) and wait for board approval before executing."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}