Skip to content

Commit 23b24d7

Browse files
committed
Set default goal token budget to one million
1 parent 7f21a4f commit 23b24d7

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Server options can be configured in `opencode.json`:
6161
"auto_continue": true,
6262
"max_auto_turns": 25,
6363
"min_continue_interval_seconds": 3,
64-
"default_token_budget": null
64+
"default_token_budget": 1000000
6565
}
6666
]
6767
]
@@ -75,7 +75,7 @@ Defaults:
7575
- `min_continue_interval_seconds`: `3`
7676
- `register_command`: `true`
7777
- `command_name`: `"goal"`
78-
- `default_token_budget`: `null`
78+
- `default_token_budget`: `1000000`
7979

8080
## Goal Workflow
8181

@@ -87,7 +87,7 @@ Use `/goal <objective>` in a fresh OpenCode chat to create a long-running goal:
8787

8888
Bare `/goal` reports the current goal state. `/goal clear` clears the goal. The TUI also includes a `Goal` command-palette entry for viewing, refreshing, or clearing the current goal state without creating a new goal.
8989

90-
By default, `/goal <objective>` omits `token_budget`, matching Codex TUI behavior. If you want every new slash-created goal to use a fixed token budget without prompting the user, set `default_token_budget` to a positive integer in `opencode.json`.
90+
By default, `/goal <objective>` creates the goal with `token_budget: 1000000`. To omit the budget, set `default_token_budget` to `null`. To use a different fixed budget without prompting the user, set `default_token_budget` to another positive integer in `opencode.json`.
9191

9292
When writing the objective, include the scope, non-goals, and verification path when they matter. The agent is reminded to audit real files, command output, tests, or PR state before closing the goal.
9393

src/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ type UpdateGoalArgs =
4141
const DEFAULT_MAX_AUTO_TURNS = 25
4242
const DEFAULT_CONTINUE_INTERVAL_SECONDS = 3
4343
const DEFAULT_COMMAND_NAME = "goal"
44+
const DEFAULT_TOKEN_BUDGET = 1_000_000
4445

4546
function defaultTokenBudgetFromOptions(options?: Options) {
4647
const budget = options?.default_token_budget
47-
if (budget == null) return null
48+
if (budget === null) return null
49+
if (budget === undefined) return DEFAULT_TOKEN_BUDGET
4850
return Number.isInteger(budget) && budget > 0 ? budget : null
4951
}
5052

test/server.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ test("server plugin registers goal as a desktop/web command by default", async (
7777
expect(config.command?.goal?.description).toBe("Set or view the long-running session goal")
7878
expect(config.command?.goal?.template).toContain('OpenCode goal mode command "/goal" was invoked')
7979
expect(config.command?.goal?.template).toContain("$ARGUMENTS")
80-
expect(config.command?.goal?.template).toContain("By default, omit token_budget")
80+
expect(config.command?.goal?.template).toContain("pass token_budget: 1000000")
8181
})
8282

8383
test("server plugin can configure a default token budget for /goal commands", async () => {
@@ -100,6 +100,26 @@ test("server plugin can configure a default token budget for /goal commands", as
100100
expect(config.command?.goal?.template).toContain("pass token_budget: 100000")
101101
})
102102

103+
test("server plugin can omit token budget for /goal commands", async () => {
104+
const hooks = await plugin.server(
105+
{
106+
client: {
107+
session: {
108+
promptAsync: async () => {},
109+
},
110+
},
111+
} as never,
112+
{ auto_continue: false, default_token_budget: null },
113+
)
114+
const config = {} as {
115+
command?: Record<string, { description?: string; template: string }>
116+
}
117+
118+
await hooks.config?.(config as never)
119+
120+
expect(config.command?.goal?.template).toContain("By default, omit token_budget")
121+
})
122+
103123
test("server plugin does not overwrite an existing goal command", async () => {
104124
const hooks = await plugin.server(
105125
{

0 commit comments

Comments
 (0)