{"record":{"id":"1d28c665c6aee23b","repo":"paperclipai/paperclip","slug":"agent-not-assigned","errorCode":"agent_not_assigned","errorMessage":"agent_not_assigned: The selected agent is not assigned to this issue.","messagePattern":"agent_not_assigned: The selected agent is not assigned to this issue\\.","errorType":"error_code","errorClass":"RunnerGoalActionError","httpStatus":null,"severity":"error","filePath":"server/src/services/runner-goals.ts","lineNumber":360,"sourceCode":"      goal,\n      workingNow: goal?.workingNow ?? false,\n      activeRunId: activeRun?.id ?? null,\n      pendingAction: projectedPendingAction,\n      revision: session?.goalRevision ?? 0,\n      observedAt: session?.goalObservedAt?.toISOString() ?? null,\n    };\n  }\n\n  async function act(\n    companyId: string,\n    issueId: string,\n    request: RunnerGoalActionRequest,\n  ): Promise<RunnerGoalActionAccepted> {\n    const binding = await readBinding(companyId, issueId, request.agentId);\n    if (!binding) throw new RunnerGoalActionError(\"issue_not_found\", \"Issue not found.\");\n    if (!binding.agent) throw new RunnerGoalActionError(\"agent_not_found\", \"Agent not found.\");\n    if (binding.issue.assigneeAgentId !== request.agentId) {\n      throw new RunnerGoalActionError(\"agent_not_assigned\", \"The selected agent is not assigned to this issue.\");\n    }\n    const fallbackCapability = capabilityForAgent(binding.agent);\n    const initialProjection = await projection(companyId, issueId, request.agentId);\n    if (!initialProjection) throw new RunnerGoalActionError(\"issue_not_found\", \"Issue not found.\");\n    if (initialProjection.capability.availability !== \"available\") {\n      throw new RunnerGoalActionError(\n        initialProjection.capability.reasonCode ?? \"session_goals_unsupported\",\n        initialProjection.capability.reason ?? \"Session goals are unsupported.\",\n      );\n    }\n\n    const accepted = await db.transaction(async (tx) => {\n      await tx.insert(agentTaskSessions).values({\n        companyId,\n        agentId: request.agentId,\n        adapterType: binding.agent!.adapterType,\n        taskKey: issueId,\n      }).onConflictDoNothing();","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/runner-goals.ts#L342-L378","documentation":"The runner goal action API (`act` in server/src/services/runner-goals.ts) validates that the agentId in the request is the current assignee of the issue. It throws RunnerGoalActionError with code `agent_not_assigned` when `binding.issue.assigneeAgentId !== request.agentId`. This enforces the single-assignee task model: only the assigned agent may manage session goals.","triggerScenarios":"Calling POST session-goal act (RunnerGoalActionRequest) with an agentId that exists in the binding but is not `issue.assigneeAgentId` — e.g. a non-assignee agent trying to pause/resume/clear/set goals on an issue assigned to a different agent.","commonSituations":"Board or tooling sends the wrong agent id; an issue was reassigned to another agent after the session was created; automated scripts iterate over agents and hit issues they don't own.","solutions":["Fetch the issue and check `assigneeAgentId` before calling, and use that agent's id in the request","Re-read the issue (assignment may have changed) and retry with the current assignee","If your agent should own the issue, reassign it first through the issue assignment API","Check company scoping: ensure you are querying the right company/issue so the binding matches your agent"],"exampleFix":"// before\nawait runnerGoals.act(companyId, issueId, { agentId: someAgentId, action: 'pause', ... });\n// after\nconst issue = await getIssue(companyId, issueId);\nif (!issue || issue.assigneeAgentId !== someAgentId) return; // or use issue.assigneeAgentId\nawait runnerGoals.act(companyId, issueId, { agentId: issue.assigneeAgentId, action: 'pause', ... });","handlingStrategy":"validation","validationCode":"const issue = await getIssue(companyId, issueId);\nif (!issue || issue.assigneeAgentId !== agentId) {\n  throw new Error(`agent ${agentId} is not the assignee of issue ${issueId}`);\n}","typeGuard":"function isAssigned(issue, agentId) {\n  return issue != null && issue.assigneeAgentId === agentId;\n}","tryCatchPattern":"try {\n  await runnerGoals.act(companyId, issueId, req);\n} catch (e) {\n  if (e instanceof RunnerGoalActionError && e.code === 'agent_not_assigned') {\n    // refresh assignment or reassign, then retry with issue.assigneeAgentId\n  } else throw e;\n}","preventionTips":["Always read the issue's assigneeAgentId immediately before goal actions","Pass issue.assigneeAgentId as the request agentId, never a cached value","Re-fetch assignment after any reassignment event","Scope automation to a single assigned agent per issue"],"tags":["authorization","assignment","issue","agent"],"backgroundTag":"permission-denied","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}