Repository navigation
feat(core): add Code Mode checks with static tool scanning to schedules - #60140
Merged
Merged
Conversation
kitlangton
force-pushed
the
schedules-code-checks
branch
from
October 29, 2026 07:31
4aacd88 to
3ade006
Compare
kitlangton
force-pushed
the
schedules-shell-checks
branch
from
October 29, 2026 16:58
2f21615 to
64d6f83
Compare
kitlangton
force-pushed
the
schedules-code-checks
branch
from
October 29, 2026 18:36
3ade006 to
5cb8a99
Compare
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Schedules can now run a Code Mode JavaScript check (
if: { code }oruntil: { code }) before waking a session, using the samestateand unattended lifecycle as shell checks, with no model call and noallowlist to maintain.Builds on #60137 (merged). Everything stays behind
experimental.schedules, and requires no new database migration.💡 Why
Shell checks cover local CLIs, while integrations like Slack, Linear, and MCP servers hold OAuth credentials inside OpenCode and often want structured JSON cursor state between checks.
🆕 Now you can
{ code: "..." }toiforuntilonschedule_createor/api/experimental/schedule. OpenCode walks the Acorn AST at creation (CodeMode.scanTools) to find everytools.<path>(...)call statically, rejects dynamictools[x]or aliasing, authorizes those tools once without saving a project-wide grant, and exposes only those tools (with nofetch) on unattended ticks.state,nowandrunsdirectly as globals (seeded at creation oneveryanduntilso events before the first tick aren't missed), and return either a boolean (until) or{ wake, state?, message? }.opencode.schedule_*,session_move,worktree_*, andedittools) out of unattended checks automatically.🚦 How it ships
Off by default behind
experimental.schedules, same as #59401, #59457 and #60137.schedule_create({ when, if / until: { code }, prompt }) + -> CodeMode.scanTools(code) extracts static `tools.<path>(...)` calls from the AST + -> authorize extracted tools once (no `save`), seed initial `state` at t = 0 + -> on each tick: run confined Code Mode over only extracted tools (no `fetch`, no model call) -> wake only when `wake: true`, appending `message` to `prompt`📊 Proof: 4 new AST scanner and binding tests in
@opencode/codemode, 46 core schedule/tool/codemode tests (coveringt=0state seeding, wake-onlyends.times, boolean and state-freeuntilreturns,fetchabsence, static tool extraction, one-time approval, denied secondary permissions, and forbidden recursive/edit tools), and 1 end-to-end server API test.👀 Read:
packages/codemode/src/scan.ts(scanTools) andauthorizeCode/runCodeinpackages/core/src/schedule/check.ts.Tool.Servicestays free ofPermission.Service:ScheduleCheckowns thePermission.Unattendedscope, whileTool.checkonly filters the inventory. The rest is routine (schema, OpenAPI, generated client).Planned feature · no user reports · not measured
Checks run
bun test test/scan.test.ts(codemode): 4 pass, 0 failbun run script/test.ts test/schedule.test.ts test/tool-schedule.test.ts test/codemode.test.ts(core): 46 pass, 0 failbun test test/schedule.test.ts(server): 1 pass, 0 failbun run check(full repo lint,sdk-docs, and 35-package turbo typecheck): pass