Repository navigation
feat(session): add /goal that keeps working until the condition is met - #75
Open
yukihamada wants to merge 1 commit into
Open
yukihamada wants to merge 1 commit into
yukihamada wants to merge 1 commit into
Conversation
…he condition is met
`/goal <condition>` stores the goal in session metadata and starts the work.
After each finished turn a small reviewer model (hidden `goal` agent, small
model by default) reads a clipped log of the work and answers done /
continue / blocked. On continue, a short synthetic reminder ("goal / not met
yet / next step") starts another turn.
Stops on: done, blocked, the round limit (default 20, SENTE_GOAL_MAX_ROUNDS),
the same missing point three times in a row, the user typing or interrupting,
and any turn that ends early (error, refused cost approval). Continuations
are ordinary turns, so the existing request cost limit (/cost) still asks.
While a goal is active it replaces the todo follow-up, so the two never both
add a turn. The re-statement after compaction goes after the first message,
not at the cached tail.
TUI: `ゴール n/max` next to the usage line, `/goal` and `/goal clear` handled
locally, a toast when the goal is met or stops. `sente run --goal "<cond>"`
(and --goal-max-rounds) runs the same loop and prints the outcome. A user's
own `goal` command keeps working: its text joins the kickoff.
SENTE_GOAL_LOOP=0 turns the loop off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
This branch has not been deployed
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.
概要
/goal <完了条件>を追加しました。ターンが終わるたびに小さい判定モデルが完了条件を照合し、未達なら短いリマインダーを付けて自動で次のターンを続けます(Claude Code / Codex / Grok の /goal と同じ使い方。本家 OpenCode anomalyco#59437 / anomalyco#65788 の設計を Sente の従来経路packages/sente/src/session/*に移植)。使い方
/goal <完了条件>設定して開始 //goal現在のゴールと進捗 //goal clear解除 //goal resume停止中のゴールを再開sente run --goal "<条件>" [--goal-max-rounds N]非対話でも同じループ。終了時に「ゴール達成: …」「ゴール停止: …」を表示(--format jsonではgoalイベント)設計
goal(id / 条件 / status / rounds / maxRounds / reason / repeats)。TUI・run・SDK のどれからでも同じ状態を見て解除できる。fork には引き継がないgoalエージェント(既定は small_model → 無ければ会話のモデル)に、ゴール開始以降の作業ログ(発話・ツール入出力を切り詰め、最新24k字まで)と未完了 todo を渡し、VERDICT / REASON / NEXTの行形式で回答させる(小さいモデルで JSON が壊れやすいため。JSON 回答も受理)。使えない回答は1回だけ再試行SENTE_GOAL_MAX_ROUNDS/--goal-max-rounds、上限到達時は判定を呼ばず停止)④利用者の入力・中断(esc)⑤同じ未達理由が3回連続(表記ゆれは bigram 類似度 0.85 で同一扱い)⑥エラー・承認拒否でターンが途中終了goalコマンド(~/.config/sente/command/goal.md等)がある場合: その本文を追加指示としてキックオフに添える。SENTE_GOAL_LOOP=0でループを無効化して従来のテンプレートコマンドに戻せるゴール 3/20(英語goal 3/20)。/goalと/goal clearは手元で処理。達成・停止時に理由付きトーストテスト
packages/sente:bun run typecheck通過bun test test/session/goal.test.ts14 pass(解析・上限・同一理由3回・判定行解析・割り込み判定・リマインダー位置・作業ログ)bun test test/session/prompt.test.ts -t goal9 pass(完了で停止 / 未達で継続 / 上限で停止 / 同一理由3回で停止 / 中断で停止 / 利用者入力で停止 / todo-followup と二重にならない / blocked・表示・clear / 利用者独自 goal コマンド)packages/tui:bun run typecheck通過、bun test464 pass(新規test/util/goal.test.ts5件)headless-model-fallbackでも同じ失敗を確認): prompt.test.ts の7件(static loop consumes queued replies / loop defers compaction… / loop compacts and continues tool results… / loop sets status to busy then idle / cancel interrupts loop… / prompt submitted during an active run… / assertNotBusy…)、llm.test.ts の3件(openai-compatible / Anthropic Compatible / Gemini payload)、server/plugin の3件(openai.ws / workflow.js P0-1 / session HttpApi v2 unavailable)run --goal追加分を更新。base で既に古かったstats --completion分も同時に更新されています実機確認(teai/cheap、費用上限 $0.3)
sente run --goal "count.txt に1〜3を書いて cat で確認"→ 1ターンで「ゴール達成」sente run --goal-max-rounds 2 --goal "plan.txt を書き、別のターンで result.txt…"→ 判定が「未達の点: result.txt 未作成」→ 自動継続1回 → 「ゴール達成」(rounds=1)/goal note.txt に hi と書いて cat で確認→ 実行中フッターにゴール 0/20、完了後に消える。/goalで状態トースト、/goal clearで metadata から削除を確認既知の制限
activeのまま残る(次の利用者入力で停止扱いになる)。本家の boot ID 方式は未導入🤖 Generated with Claude Code