Repository navigation
fix(session): detect doom loops across assistant turns - #9
Closed
yukihamada wants to merge 44 commits into
Closed
yukihamada wants to merge 44 commits into
yukihamada wants to merge 44 commits into
Conversation
ci(release): restore sente release workflows lost in upstream merge
Measured on M-series TUI first draw: bytecode 1390ms vs no-bytecode 1550ms (~160ms saved) but binary grows from ~142MB to ~334MB and RSS rises. The ~2x size / per-launch savings tradeoff is not worth; bytecode stays opt-in via --bytecode flag.
opencode serve still works by proxying teai.io/sente/app when the UI is not embedded. Interactive/CLI users unaffected; serve online path unchanged.
Sente を初めて開いたときに1回だけチュートリアルを出す(2026-09-13本人要望)。 「何ができるか」と「自分の声を登録する導線(koe.live/enroll)」を案内する。 - src/onboarding.ts: 表示条件とキー名を集約。KV は非同期なので ready を待つ (待たないと「初回なのに出ない」「毎回出る」が起きる) - src/ui/dialog-onboarding.tsx: ダイアログ本体。e で声の登録ページを開く - src/app.tsx: プラグイン読み込み完了(ready)後に1回だけ dialog.replace - test/onboarding.test.ts: 表示条件のテスト4件 二度と出さない印は KV(~/.local/state/sente/kv.json の onboarding_completed)。 CLI 側の ~/.config/teai/intro-seen-* とは別管理。 検証: bun turbo typecheck 30/30 green / packages/tui の bun test 197 pass 0 fail
bun.lock の integrity が実体と食い違い、bun install が 「Integrity check failed for tarball」で1パッケージ失敗していた。 結果 @sente-ai/client が入らず、session-ui を参照する enterprise の typecheck が Cannot find module '@sente-ai/client/promise' で落ち、 husky pre-push が通らずリリース push ができない状態だった。 tarball 自体は正常(tar -tzf で検証済)なので、ハッシュを実体に合わせるのみ。 変更は bun.lock の2行。 検証: bun install が「1 package installed」で成功 → bun turbo typecheck 30/30 green
…nding
teai のストリームが途中で失敗したときの文面
「Generation did not complete. Retry shortly.」がどの再試行パターンにも
当たらず、再送すれば成功する一時障害なのに「再試行しないエラー」として
打ち切られていた。
再試行対象に追加する。サーバ側(teai.io)が実際の理由を本文に埋め込む
ようになったため、その中身に既存パターン(5xx 等)が含まれる場合も
ここで拾える。
検証: bun test test/session/retry.test.ts = 65 pass / 0 fail
bun typecheck = 通過
Adopt the agent-first CLI convention from block/buzz so a caller can branch
on the exit code alone without parsing human-readable output.
- src/cli/exit-code.ts: 0 success / 1 user / 2 network / 3 auth / 4 other /
5 conflict, plus exitCodeForError() mapping named and tagged errors onto it
- run.ts: replace 10 undifferentiated process.exit(1) calls with classified
codes; auth failures now exit 3 so callers stop retrying in a loop
- run.ts: --format json now keeps stdout a pure event stream and emits every
warning (unknown agent, share URL, auto-rejected permission) to stderr as a
structured {type:diagnostic} record instead of ANSI-styled prose
- error records carry exitCode so a consumer reads the classification from the
stream as well as from the process status
Verified: 9/9 unit tests, 30/30 turbo typecheck, oxlint 0 errors, and
measured exit=1 with pure-JSON stderr across the usage-error paths.
Subprocess tests remain failing in this environment on the base commit too
(SENTE_CONFIG in the ambient shell overrides SENTE_CONFIG_CONTENT), so the
new end-to-end assertions were dropped rather than left red.
The contract landed in `sente run` (86d041f) but `sente tui` still used bare `process.exitCode = 1`. All five sites are pre-launch argument validation (--replay, --mini with network flags, unsupported --mini-only options, --fork without a session, and worker connection failure), so all five are ExitCode.User — the classification is unchanged, but it is now stated instead of implied, and a future change cannot silently drift. TUI remains interactive: it does not gain --format json, so no structured output is added here. Verified: 30/30 turbo typecheck, oxlint 0 errors, measured exit=1 for --replay and --fork, and no new failures against the baseline.
…dicate The launcher already used 75 (SENTE_RESTART_EXIT_CODE) for the TUI's "compact and resume" request, but it was invisible to the contract — a supervisor reading exit-code.ts would have classified it as Other and retried it like a transient failure. - ExitCode.Restart = 75, deliberately outside 0-5 so it cannot collide - shouldRestart(code): true only for Network(2), Other(4) and Restart(75). Permanent failures (User 1, Auth 3, Conflict 5) return false. The predicate exists because launchd KeepAlive restarts on any exit: a bad flag or an expired key becomes an infinite loop. That is not hypothetical — it burned ~4.3M credits over three days in 2026-09. Verified: 14/14 unit tests including the KeepAlive cases, 30/30 typecheck.
…gh release (the manual Sente distribution recipe) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Pasting an email address into /login now sends a teai.io login code (/api/v1/auth/email) and a second prompt redeems it (/api/v1/auth/verify). New accounts use the auto-issued API key; existing accounts log in with the issued auth token directly. Key paste flow is unchanged.
The server now skips the browser-only Turnstile check for CLI requests carrying this header (teai.io#748), so /login's email flow works from a terminal.
Sente launched directly never read $TE_CONFIG_DIR/credentials, so /login
survived only inside the running session and the next launch resolved
{env:TEAI_API_KEY} to empty.
- Load saved credentials before command handlers and worker creation.
- Keep explicit environment overrides and scrub-mode isolation intact.
- Replace every key assignment on save and parse with the launcher's
last-assignment precedence; a duplicate line could restore the old key.
Verified with a loopback auth fixture: /login -> email -> code -> /exit ->
two fresh process config resolutions. packages/tui 241 pass / 0 fail.
高級モデルは1ターンで数千〜数万クレジットを消費しうる。残高が尽きると
推論が止まり Sente が黙るため、**モデルを選ぶ直前**に気づけるようにした。
- util/credits.ts を追加
- creditsRemaining(): provider 層が last-route.json へ退避した
x-teai-credits-remaining を読む。ファイル無し/破損/非数値は null
- isPremiumModel(): cost.output が閾値(15)を超えるモデルを高級と判定。
cost 不明なモデルは誤検知を避けるため false
- LOW_CREDITS_THRESHOLD = 10_000cr
- context/local.tsx の model.set() と model.cycle() に警告を接続
(/models からの選択と Fキー循環の両経路をカバー)
残高不明な場合は何も出さない — 推測でユーザーの選択を邪魔しないため。
検証: bun typecheck クリーン / bun test 206 pass 0 fail
yukihamada
marked this pull request as ready for review
September 24, 2026 14:55
Owner
Author
|
Validation status for head 166bf1f: branch conflicts resolved; final diff restricted to processor.ts and processor-effect.test.ts. Local focused regression suite: 87 passed, 0 failed; package typecheck passed after correcting isolated-worktree dependency links. Root lint still reports 29 errors outside this change. GitHub unit/e2e jobs remain QUEUED after a 15-minute wait; these checks have not passed or run. No merge or release performed. Existing doom_loop permissions are preserved: allow does not force a stop. Provider/native and interactive TUI paths remain unverified. |
Owner
Author
|
CI queued調査・修正(7c8261d761e9ec61f37fd6c1dd24353542e4cb8f、同一branchへ通常push済み)
https://github.com/yukihamada/opencode/actions/runs/36026653749 |
- SDK(v1/v2) が x-opencode-directory/workspace を送っていたが、サーバーは x-sente-directory を読むため書き込み系リクエストでディレクトリ指定が無視されていた - パンジャブ語(Aran スクリプト)のロケール判定を修正 - テストの期待値を現行のキー名/設定ファイル名に合わせる Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- sente-release.yml の起動条件を headless-model-fallback への push から sente-ship-* タグ push / workflow_dispatch に変更(マージ=即一般配布を止める) - タグの commit が headless-model-fallback に含まれることを検証 - SENTE_CHANNEL をリリースブランチ名に固定(タグ起動でも sente-<channel>.db を維持) - macos-14 (arm64) で darwin-arm64 tar の SHA256 照合 → --version 一致 → debug config exit 0 を通過しない限り publish しない(script/sente-release-smoke.py、隔離 HOME・課金なし) - publish ジョブを environment sente-release に分離(必須レビュアー設定で二段承認可) - ビルド時に channel が空(detached HEAD)なら失敗させる。空 channel は sente-.db に 切り替わり既存セッションが見えなくなるため - 手動の script/release-sente.sh は緊急用として非推奨化 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
ci(release): タグ push を唯一のリリース経路にし Apple Silicon 実機 smoke を必須化
bf7f487 raised the models.dev cache TTL from 5 minutes to 6 hours, but the stale-cache test still wrote an mtime 10 minutes old and expected a refetch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
完了済み回答の後に processor が compaction を要求すると、prompt.ts が即座に compaction の user メッセージを作るため最新 user ID が変わり、既存の 「回答済みなら停止」チェックを素通りして合成継続→再回答→再compaction が 繰り返されていた(完了後の課金ループ)。 ツール結果の継続が不要な完了回答では transcript を触らず外側ループへ戻し、 既存チェックで停止させる。compaction は次のユーザー入力時に実行される。 検証: bun test prompt/processor-effect/compaction 132 pass 2 skip 0 fail, bun typecheck exit 0 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
blacksmith-4vcpu-* runners are only available to the upstream org, so every test job in yukihamada/opencode stayed queued forever. Use ubuntu-latest / windows-latest. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…da/opencode into feat/doom-loop-cross-turn-20260924
…nger exists) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
Owner
Author
|
#19 で置き換え済み(マージ済み)のため close。 |
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.
Summary
Integration
Verification (macOS, Bun 1.4.0; repository specifies 1.3.14)