paperclipai/paperclip · warning · RunnerGoalActionError
goal_not_found
goal_not_found
Error message
goal_not_found: There is no current session goal.
What it means
Goal mutations edit/replace/pause/resume/clear require an existing current goal. When `storedGoal(session)` returns null (no goal was ever set, or it was cleared), `act` throws `goal_not_found`. Only 'create' is valid on a goalless session.
Source
Thrown at server/src/services/runner-goals.ts:440
? "clear"
: "set";
if (capability.availability !== "available" || !capability.actions.includes(requiredCapabilityAction)) {
throw new RunnerGoalActionError(
capability.reasonCode ?? "goal_action_unsupported",
capability.reason ?? `${request.action} is unsupported by this agent session.`,
);
}
if (request.tokenBudget != null && !capability.tokenBudgetControl) {
throw new RunnerGoalActionError(
"goal_token_budget_unsupported",
"This agent session does not support goal token budgets.",
);
}
if (request.action === "create" && currentGoal && currentGoal.status !== "complete") {
throw new RunnerGoalConflictError("replacement_required", currentProjection);
}
if (["edit", "replace", "pause", "resume", "clear"].includes(request.action) && !currentGoal) {
throw new RunnerGoalActionError("goal_not_found", "There is no current session goal.");
}
const nextRevision = session.goalRevision + 1;
const desiredState = request.action === "pause"
? "paused"
: request.action === "clear"
? null
: "active";
await tx.update(agentTaskSessions).set({
goalDesiredState: desiredState,
goalRevision: nextRevision,
updatedAt: new Date(),
}).where(eq(agentTaskSessions.id, session.id));
const pendingProjection: RunnerGoalProjection = {
...currentProjection,
pendingAction: pendingAction(request.action),
revision: nextRevision,
};View on GitHub (pinned to 01ad858492)
Solutions
- Check the projection's `currentGoal` before mutating; skip or create if null
- Use action 'create' when no goal exists instead of edit/replace/pause/resume/clear
- Refresh the projection after conflicts and adapt the action to the actual goal state
- Make pause/resume automation idempotent: treat goal_not_found as a no-op
Example fix
// before
await act(companyId, issueId, { agentId, action: 'pause', ... });
// after
const proj = await projection(companyId, issueId, agentId);
if (!proj.currentGoal) return; // nothing to pause
await act(companyId, issueId, { agentId, action: 'pause', ... }); Defensive patterns
Strategy: type-guard
Validate before calling
const proj = await runnerGoals.projection(companyId, issueId, agentId);
if (!proj.currentGoal) return { skipped: true, reason: 'no current goal' }; Type guard
function hasActiveGoal(proj) {
return proj?.currentGoal != null;
} Try / catch
try {
await runnerGoals.act(companyId, issueId, req);
} catch (e) {
if (e instanceof RunnerGoalActionError && e.code === 'goal_not_found') {
// treat as no-op or create a goal first
return await runnerGoals.act(companyId, issueId, { ...req, action: 'create', goal: defaultGoal });
}
throw e;
} Prevention
- Gate edit/replace/pause/resume/clear on currentGoal != null
- Make pause/resume automations tolerant of a missing goal
- Re-read the projection after clears/completions before further actions
- Enable goal controls only when a goal is present
When it happens
Trigger: Calling pause/resume/clear/edit/replace when the session has no goal; pausing after the goal auto-completed and was cleared; scripts replaying pause/resume after a session restart that lost the goal.
Common situations: UI buttons enabled without checking currentGoal; race where another actor cleared the goal first; assuming the goal from a previous session persists; goal completed and pruned before a resume arrives.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- workflow eval run ${input.runId} is missing
- session_unavailable
- replacement_required
- Job not found
- Probe found no matching Anthropic Environment
AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-10).
Data as JSON: /api/errors/20fcfd21da2bfea4.
Report an issue: GitHub.