Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/common/utils/goals/resolveGoalSetIntent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,27 @@ describe("resolveModelGoalSetIntent", () => {
expect(intent.turnCap).toBe(8);
});

test("honors no-budget defaults for model tools without treating null as explicit clear", () => {
test("applies the positive budget default even when user-authored goals may omit budgets", () => {
const intent = resolveModelGoalSetIntent(
{ objective: "ship", budgetCents: null, turnCap: null },
{ ...defaults, alwaysRequireExplicitBudget: false, defaultTurnCap: null }
);

expect(intent.budgetCents).toBe(500);
expect(intent.turnCap).toBeNull();
});

test("resolves to unbounded only when effective defaults have no positive budget or turn cap", () => {
const intent = resolveModelGoalSetIntent(
{ objective: "ship", budgetCents: null, turnCap: null },
{
...defaults,
defaultBudgetCents: 0,
defaultTurnCap: null,
alwaysRequireExplicitBudget: false,
}
);

expect(intent.budgetCents).toBeNull();
expect(intent.turnCap).toBeNull();
});
Expand Down
6 changes: 3 additions & 3 deletions src/common/utils/goals/resolveGoalSetIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export function resolveGoalSetIntent(
* providers. For agent-created goals, `null` must therefore mean "use the
* effective defaults" rather than the UI meaning "the user explicitly cleared
* this bound"; otherwise a model could accidentally create an unbounded goal.
* The budget default applies even when user-authored forms allow omitted
* budgets to mean "no budget" — a model omission is not an explicit user clear.
*/
export function resolveModelGoalSetIntent(
input: GoalSetIntentInput,
Expand All @@ -110,9 +112,7 @@ export function resolveModelGoalSetIntent(
const budgetCents =
input.budgetCents != null
? normalizeGoalBudgetCents(input.budgetCents)
: defaults.alwaysRequireExplicitBudget
? normalizeGoalBudgetCents(defaults.defaultBudgetCents)
: null;
: normalizeGoalBudgetCents(defaults.defaultBudgetCents);
const turnCap = input.turnCap ?? defaults.defaultTurnCap;

return {
Expand Down
21 changes: 21 additions & 0 deletions src/node/services/tools/goal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,27 @@ describe("goal tools", () => {
expect(result).toMatchObject({ goal: { budgetCents: 450, turnCap: 3 } });
});

test("set_goal uses positive default budget even when omitted user budgets are allowed", async () => {
const tool = createSetGoalTool({
cwd: "/tmp",
runtimeTempDir: "/tmp",
runtime: inertRuntime,
workspaceId,
goalService,
goalDefaults: {
defaultBudgetCents: 650,
defaultTurnCap: null,
alwaysRequireExplicitBudget: false,
},
});

const result: unknown = await Promise.resolve(
tool.execute!({ objective: "Use global budget default" }, mockToolCallOptions)
);

expect(result).toMatchObject({ goal: { budgetCents: 650, turnCap: null } });
});

test("set_goal accepts explicit positive budget and turn cap", async () => {
const tool = createSetGoalTool({
cwd: "/tmp",
Expand Down
2 changes: 1 addition & 1 deletion src/node/services/tools/set_goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const createSetGoalTool: ToolFactory = (config) => {
assertResolvedModelGoalBounds(resolved);
if (resolved.budgetCents == null && resolved.turnCap == null) {
throw new Error(
"set_goal requires a budget or turn cap for model-created goals. Ask the user to provide a budget/turn cap or configure workspace goal defaults."
"set_goal requires a budget or turn cap for model-created goals. Ask the user to provide one, or configure a positive effective default goal budget/turn cap."
);
}

Expand Down
Loading