Repository navigation
feat(session): add /goal slash command for stated session goal (RES-932) - #31
Conversation
Pins a user-stated session goal to the session row so every model turn's
system prompt includes it, keeping the agent centered on the objective
across the conversation. Optional --budget and --time values are parsed
from the same single-field dialog input (e.g. /goal Ship paper
--budget=$50 --time=2h) and rendered alongside the goal in the system
block. Submitting an empty value clears the goal.
- DB: new session.goal JSON column + drizzle migration
- Session service: setGoal/clearGoal + Session.goalSystemPrompt renderer
- Server: PATCH /session/:id accepts {goal} on update payload
- SDK: regenerated update() signature exposes goal field
- TUI: /goal opens a single-field dialog with inline flag parsing
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (10)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reverting in favor of upstream opencode#27163 ("feat: add native
session goals", opened 2026-05-12, still open). Upstream ships:
- Token + wall-clock usage accounting with budget-exhausted state
- Model-facing read/create/mark-complete tools (a real forcing
function — model can't ignore a passive system-prompt block the
way it could here)
- Auto-continue-on-idle + pause-on-abort
- TUI prompt-input / session-header / footer surfaces
- Real SDK codegen output (vs the hand-patched sdk.gen.ts /
types.gen.ts in this PR that next regen would clobber)
- 1243+ lines of test coverage vs ~120 here
PR #31's own "Followups (deferred)" section explicitly listed three
items upstream already provides: SDK regen, footer/status-bar
surface, real budget/time tracking. The implementation here was
display-only prompt injection with no enforcement.
Plan: wait for upstream anomalyco#27163 to merge, then sync via the normal
upstream-merge path. The gpd-cli companion (get-physics-done#228)
is a distinct surface (CLI, not in-runtime) and can land on its
own merits once it consumes the upstream-merged shape.
Cameron's f6a9017 on top (extending the RES-904 reward-hacking
gate to gpt/gemini/codex/kimi/trinity) touches a disjoint file set
and is preserved unchanged.
Reverts the 12 files PR #31 modified/added to their state at the
PR #30 merge (fb230ed):
packages/opencode/migration/20260515120000_add_session_goal/migration.sql (deleted)
packages/opencode/src/cli/cmd/tui/component/dialog-session-goal.tsx (deleted)
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx (restored)
packages/opencode/src/server/instance/session.ts (restored)
packages/opencode/src/session/index.ts (restored)
packages/opencode/src/session/projectors.ts (restored)
packages/opencode/src/session/prompt.ts (restored)
packages/opencode/src/session/session.sql.ts (restored)
packages/opencode/test/cli/tui/dialog-session-goal.test.ts (deleted)
packages/opencode/test/session/goal.test.ts (deleted)
packages/sdk/js/src/v2/gen/sdk.gen.ts (restored)
packages/sdk/js/src/v2/gen/types.gen.ts (restored)
Summary
Adds a
/goalslash command to the TUI that pins a user-stated session goal so the agent keeps it in view across every turn. Closes RES-932.session.goalJSON column + drizzle migration) and surfaced into the system prompt on every model turn via a<session-goal>block.--budget=<v>and--time=<v>flags (e.g.Ship the paper --budget=$50 --time=2h). Submitting an empty value clears the goal — no separate/clear-goalneeded.PATCH /session/:idaccepts{goal: {...} | null}on the existing update route; the generated SDK'ssession.update()exposes the new field. The OpenAPI generator output (packages/sdk/js/src/v2/gen/) was patched by hand to match the new shape — re-runningbun run buildinpackages/sdk/jsagainst this branch should produce equivalent output.Design notes
"$50"and"2h"are passed through verbatim into the system prompt. If we later want validation/tracking, the schema is already shaped to absorb it./goalupdate mid-run reaches the very next model call instead of waiting for a fresh loop./renameand/share— mirrors the existing pattern for session-metadata commands.Test plan
bun run typecheck(opencode + sdk) — cleanbun test test/session/goal.test.ts test/cli/tui/dialog-session-goal.test.ts— 7/7 passbun test test/sessionfull sweep — 11 pre-existing abort/cancel timeouts (matches baseline; none touch goal logic)/goal Find quantum gravity --budget=$50 --time=2h, confirm the goal text appears in subsequent agent reasoning/goalto clearFollowups (deferred)
packages/sdk/js) to confirm the hand-patchedgoalfield matches what hey-api emits from the updated OpenAPI spec.Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]