can1357/oh-my-pi · error · ToolError
objective is required when op=create
Error message
objective is required when op=create
What it means
GoalTool's create operation requires an `objective` string. validateCreateParams trims params.objective and throws this ToolError when it is empty, whitespace-only, or undefined. The tool refuses to create a goal without a stated objective.
Source
Thrown at packages/coding-agent/src/goals/tools/goal-tool.ts:49
export function buildGoalToolResponse(
goal: Goal | null | undefined,
options?: { includeCompletionReport?: boolean },
): GoalToolResponse {
const resolvedGoal = goal ?? null;
return {
goal: resolvedGoal,
remainingTokens: remainingTokens(resolvedGoal),
completionBudgetReport:
options?.includeCompletionReport && resolvedGoal?.status === "complete"
? completionBudgetReport(resolvedGoal)
: null,
};
}
function validateCreateParams(params: GoalToolInput): { objective: string; tokenBudget?: number } {
const objective = params.objective?.trim();
if (!objective) {
throw new ToolError("objective is required when op=create");
}
const tokenBudget = params.token_budget;
if (tokenBudget !== undefined && (!Number.isInteger(tokenBudget) || tokenBudget <= 0)) {
throw new ToolError("token_budget must be a positive integer when provided");
}
return { objective, tokenBudget };
}
export class GoalTool implements AgentTool<typeof goalSchema, GoalToolDetails> {
readonly name = "goal";
readonly label = "Goal";
readonly description = prompt.render(goalDescription);
readonly parameters = goalSchema;
readonly strict = true;
readonly intent = "omit" as const;
readonly #session: ToolSession;
constructor(session: ToolSession) {View on GitHub (pinned to 9690622007)
Solutions
- Pass a non-empty `objective` string in the tool input, e.g. {"op":"create","objective":"Refactor auth module"}
- Trim-check the objective at the call site before invoking the tool
- If building calls from a schema, ensure goalSchema marks objective required for op=create so the model is constrained
Example fix
// before
await tool.execute({ op: "create" });
// after
await tool.execute({ op: "create", objective: "Ship the v2 API" }); Defensive patterns
Strategy: validation
Validate before calling
if (typeof input.objective !== "string" || input.objective.trim().length === 0) {
throw new Error("objective must be a non-empty string before op=create");
} Type guard
function hasObjective(p: { objective?: string }): p is { objective: string } {
return typeof p.objective === "string" && p.objective.trim().length > 0;
} Try / catch
try {
await goalTool.execute({ op: "create", objective });
} catch (err) {
if (err instanceof ToolError && err.message.includes("objective is required")) {
// prompt user/model for an objective and retry
} else throw err;
} Prevention
- Always supply objective when op=create; only omit it for other ops
- Trim user/model-provided text before passing
- Constrain model tool calls via the goalSchema so objective is required
When it happens
Trigger: Calling the `goal` tool with op="create" and omitting `objective`, passing `objective: ""` or `objective: " "` (whitespace-only), or passing a non-string that trims to nothing.
Common situations: An LLM agent emits a goal-create tool call but leaves out the objective field; programmatic tool invocations build the params object without the required field; templates copy an update/status call shape (no objective needed) and reuse it for create.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- token_budget must be a positive integer when provided
- `pat` must be a non-empty pattern
- skip must be a non-negative number
- Empty report. ${reportIssueDeviceUsage()}
- Invalid report format. ${reportIssueDeviceUsage()}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/5f8762b1c9032fcf.
Report an issue: GitHub.