{"record":{"id":"e32ebfc46b7db2b1","repo":"can1357/oh-my-pi","slug":"goal-mode-is-not-active","errorCode":null,"errorMessage":"Goal mode is not active.","messagePattern":"Goal mode is not active\\.","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/goals/tools/goal-tool.ts","lineNumber":80,"sourceCode":"\treadonly parameters = goalSchema;\n\treadonly strict = true;\n\treadonly intent = \"omit\" as const;\n\treadonly #session: ToolSession;\n\n\tconstructor(session: ToolSession) {\n\t\tthis.#session = session;\n\t}\n\n\tasync execute(\n\t\t_toolCallId: string,\n\t\tparams: GoalToolInput,\n\t\t_signal?: AbortSignal,\n\t\t_onUpdate?: AgentToolUpdateCallback<GoalToolDetails>,\n\t\t_context?: AgentToolContext,\n\t): Promise<AgentToolResult<GoalToolDetails>> {\n\t\tconst runtime = this.#session.getGoalRuntime?.();\n\t\tif (!runtime) {\n\t\t\tthrow new ToolError(\"Goal mode is not active.\");\n\t\t}\n\n\t\tlet response: GoalToolResponse;\n\t\tif (params.op === \"create\") {\n\t\t\tconst created = await runtime.createGoal(validateCreateParams(params));\n\t\t\tresponse = buildGoalToolResponse(created.goal);\n\t\t} else if (params.op === \"get\") {\n\t\t\tconst state = this.#session.getGoalModeState?.();\n\t\t\tresponse = buildGoalToolResponse(state?.goal ?? null);\n\t\t} else if (params.op === \"resume\") {\n\t\t\tconst resumed = await runtime.resumeGoal();\n\t\t\tresponse = buildGoalToolResponse(resumed.goal);\n\t\t} else if (params.op === \"drop\") {\n\t\t\tconst dropped = await runtime.dropGoal();\n\t\t\tresponse = buildGoalToolResponse(dropped ?? null);\n\t\t} else {\n\t\t\tconst completed = await runtime.completeGoalFromTool();\n\t\t\tresponse = buildGoalToolResponse(completed, { includeCompletionReport: true });","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/goals/tools/goal-tool.ts#L62-L98","documentation":"The goal tool delegates to a goal runtime fetched from the session via session.getGoalRuntime?.(). When the runtime is absent — goal mode was never activated or has been disabled — execute throws this ToolError instead of performing any operation.","triggerScenarios":"Invoking the `goal` tool (any op: create/update/status) in a session where goal mode is not active, e.g. the session wasn't started with goal mode enabled or the runtime was not installed on the session.","commonSituations":"Agent tries to use the goal tool in a normal (non-goal-mode) run; configuration toggles goal mode off; embedding the agent SDK without wiring a GoalRuntime onto the session.","solutions":["Enable goal mode for the session before using the goal tool","Verify the session was constructed with a goal runtime (getGoalRuntime returns one)","Guard tool availability: only expose/register the goal tool when goal mode is active"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const runtime = session.getGoalRuntime?.();\nif (!runtime) throw new Error(\"Enable goal mode before calling the goal tool\");","typeGuard":"function goalModeActive(s: Session): boolean {\n  return typeof s.getGoalRuntime === \"function\" && s.getGoalRuntime() != null;\n}","tryCatchPattern":"try {\n  await goalTool.execute(params, _sig, _signal, _onUpdate, ctx);\n} catch (err) {\n  if (err instanceof ToolError && err.message === \"Goal mode is not active.\") {\n    // surface guidance to enable goal mode, don't retry blindly\n  } else throw err;\n}","preventionTips":["Only register/expose the goal tool in sessions where goal mode is on","Check getGoalRuntime() availability before planning goal tool calls","Document goal-mode prerequisite in agent prompts"],"tags":["tool-state","prerequisite","goal-mode"],"backgroundTag":"feature-not-enabled","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}