-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
fix: viewer model dropdown, SSE cleanup, OpenRouter URL, zh-TW mode, alias fix, restart guard, FTS5 fallback, httpcore dep #2069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "name": "Code Development (Traditional Chinese)", | ||
| "prompts": { | ||
| "footer": "IMPORTANT! DO NOT do any work right now other than generating this OBSERVATIONS from tool use messages - and remember that you are a memory agent designed to summarize a DIFFERENT claude code session, not this one.\n\nNever reference yourself or your own actions. Do not output anything other than the observation content formatted in the XML structure above. All other output is ignored by the system, and the system has been designed to be smart about token usage. Please spend your tokens wisely on useful observations.\n\nRemember that we record these observations as a way of helping us stay on track with our progress, and to help us keep important decisions and changes at the forefront of our minds! :) Thank you so much for your help!\n\nLANGUAGE REQUIREMENTS: Please write the observation data in 繁體中文", | ||
|
|
||
| "xml_title_placeholder": "[**title**: 捕捉核心行動或主題的簡短標題]", | ||
| "xml_subtitle_placeholder": "[**subtitle**: 一句話解釋(最多24個單詞)]", | ||
| "xml_fact_placeholder": "[簡潔、獨立的陳述]", | ||
| "xml_narrative_placeholder": "[**narrative**: 完整背景:做了什麼、如何運作、為什麼重要]", | ||
| "xml_concept_placeholder": "[知識類型類別]", | ||
| "xml_file_placeholder": "[檔案路徑]", | ||
|
|
||
| "xml_summary_request_placeholder": "[捕捉使用者請求和討論/完成內容實質的簡短標題]", | ||
| "xml_summary_investigated_placeholder": "[到目前為止探索了什麼?檢查了什麼?]", | ||
| "xml_summary_learned_placeholder": "[你了解到了什麼運作原理?]", | ||
| "xml_summary_completed_placeholder": "[到目前為止完成了什麼工作?發佈或更改了什麼?]", | ||
| "xml_summary_next_steps_placeholder": "[在此會話中,你正在積極處理或計劃接下來處理什麼?]", | ||
| "xml_summary_notes_placeholder": "[關於當前進度的其他見解或觀察]", | ||
|
|
||
| "continuation_instruction": "IMPORTANT: Continue generating observations from tool use messages using the XML structure below.\n\nLANGUAGE REQUIREMENTS: Please write the observation data in 繁體中文", | ||
|
|
||
| "summary_footer": "IMPORTANT! DO NOT do any work right now other than generating this next PROGRESS SUMMARY - and remember that you are a memory agent designed to summarize a DIFFERENT claude code session, not this one.\n\nNever reference yourself or your own actions. Do not output anything other than the summary content formatted in the XML structure above. All other output is ignored by the system, and the system has been designed to be smart about token usage. Please spend your tokens wisely on useful summary content.\n\nThank you, this summary will be very useful for keeping track of our progress!\n\nLANGUAGE REQUIREMENTS: Please write ALL summary content (request, investigated, learned, completed, next_steps, notes) in 繁體中文" | ||
| } | ||
| } |
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /** | ||
| * RestartGuard: Time-windowed restart counter for session generators. | ||
| * | ||
| * Replaces the flat consecutiveRestarts counter with a windowed approach: | ||
| * - Only counts restarts within the last RESTART_WINDOW_MS (60 seconds) | ||
| * - Higher raw cap (10) to accommodate legitimate long sessions | ||
| * - Resets after RESTART_DECAY_MS (5 minutes) of successful processing | ||
| * | ||
| * Shared between worker-service.ts and SessionRoutes.ts to prevent | ||
| * inconsistent restart guard logic. | ||
| */ | ||
|
|
||
| import type { ActiveSession } from '../worker-types.js'; | ||
| import { logger } from '../../utils/logger.js'; | ||
|
|
||
| /** Only count restarts within this window */ | ||
| const RESTART_WINDOW_MS = 60_000; // 60 seconds | ||
|
|
||
| /** Reset counter after this much successful processing */ | ||
| const RESTART_DECAY_MS = 5 * 60_000; // 5 minutes | ||
|
|
||
| /** Maximum restarts allowed within the window */ | ||
| const MAX_WINDOWED_RESTARTS = 10; | ||
|
|
||
| /** | ||
| * Record a restart attempt and check whether the session has exceeded the limit. | ||
| * | ||
| * @returns true if the restart is allowed, false if it should be blocked | ||
| */ | ||
| export function recordRestartAndCheckAllowed(session: ActiveSession, logContext: string): boolean { | ||
| const now = Date.now(); | ||
|
|
||
| // Initialize restartTimestamps if missing (backward compat) | ||
| if (!session.restartTimestamps) { | ||
| session.restartTimestamps = []; | ||
| } | ||
|
|
||
| // Add current restart timestamp | ||
| session.restartTimestamps.push(now); | ||
|
|
||
| // Prune timestamps outside the window | ||
| session.restartTimestamps = session.restartTimestamps.filter( | ||
| ts => (now - ts) < RESTART_WINDOW_MS | ||
| ); | ||
|
|
||
| // Also maintain the legacy counter for logging | ||
| session.consecutiveRestarts = (session.consecutiveRestarts || 0) + 1; | ||
|
|
||
| const restartsInWindow = session.restartTimestamps.length; | ||
|
|
||
| if (restartsInWindow > MAX_WINDOWED_RESTARTS) { | ||
| logger.error('SYSTEM', `${logContext}: Exceeded max windowed restarts (${restartsInWindow}/${MAX_WINDOWED_RESTARTS} in ${RESTART_WINDOW_MS / 1000}s)`, { | ||
| sessionId: session.sessionDbId, | ||
| restartsInWindow, | ||
| maxRestarts: MAX_WINDOWED_RESTARTS, | ||
| windowMs: RESTART_WINDOW_MS | ||
| }); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Reset the restart counter after successful processing. | ||
| * Called when a session completes with no pending work, or after | ||
| * sustained successful processing (decay). | ||
| */ | ||
| export function resetRestartCounter(session: ActiveSession): void { | ||
| session.consecutiveRestarts = 0; | ||
| session.restartTimestamps = []; | ||
| } | ||
|
|
||
| /** | ||
| * Apply time decay: if enough time has passed since the last restart, | ||
| * clear the restart history. Call this periodically during successful processing. | ||
| */ | ||
| export function applyRestartDecay(session: ActiveSession): void { | ||
| if (!session.restartTimestamps || session.restartTimestamps.length === 0) return; | ||
|
|
||
| const now = Date.now(); | ||
| const mostRecentRestart = Math.max(...session.restartTimestamps); | ||
|
|
||
| if (now - mostRecentRestart > RESTART_DECAY_MS) { | ||
| logger.debug('SYSTEM', 'Restart counter decayed after sustained success', { | ||
| sessionId: session.sessionDbId, | ||
| previousRestarts: session.restartTimestamps.length, | ||
| decayMs: RESTART_DECAY_MS | ||
| }); | ||
| resetRestartCounter(session); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applyRestartDecayis defined but never calledapplyRestartDecayis exported but nothing in this PR (or anywhere in the diff) calls it. The docstring says "call this periodically during successful processing," but no callsite wires it up. The 5-minute decay won't happen; timestamps age out only via the 60 s window filter. Consider either connecting it to the message-processing loop or removing it until it is needed.