-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: add Opus [1M] model with correct 1M context window reporting #649
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -548,20 +548,29 @@ export function useChatSessionState({ | |||||||||||||||
| const sessionProvider = selectedSession.__provider || 'claude'; | ||||||||||||||||
| if (sessionProvider !== 'claude') return; | ||||||||||||||||
|
|
||||||||||||||||
| // Fetch initial token usage but don't overwrite a higher value from WebSocket | ||||||||||||||||
| let cancelled = false; | ||||||||||||||||
| const fetchInitialTokenUsage = async () => { | ||||||||||||||||
| try { | ||||||||||||||||
| const url = `/api/projects/${selectedProject.name}/sessions/${selectedSession.id}/token-usage`; | ||||||||||||||||
| const response = await authenticatedFetch(url); | ||||||||||||||||
| if (response.ok) { | ||||||||||||||||
| setTokenBudget(await response.json()); | ||||||||||||||||
| } else { | ||||||||||||||||
| if (response.ok && !cancelled) { | ||||||||||||||||
| const data = await response.json(); | ||||||||||||||||
| setTokenBudget((prev: Record<string, unknown> | null) => { | ||||||||||||||||
| if (prev && typeof prev.total === 'number' && prev.total > (data.total || 0)) { | ||||||||||||||||
| return prev; | ||||||||||||||||
| } | ||||||||||||||||
| return data; | ||||||||||||||||
| }); | ||||||||||||||||
| } else if (!cancelled) { | ||||||||||||||||
| setTokenBudget(null); | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+565
to
567
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid clearing existing token budget on transient fetch failures. At Line 565-Line 567, setting Suggested fix- } else if (!cancelled) {
- setTokenBudget(null);
- }
+ } else if (!cancelled) {
+ // Preserve existing budget (especially realtime WS updates) on HTTP fetch failures.
+ setTokenBudget((prev: Record<string, unknown> | null) => prev);
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| } catch (error) { | ||||||||||||||||
| console.error('Failed to fetch initial token usage:', error); | ||||||||||||||||
| } | ||||||||||||||||
| }; | ||||||||||||||||
| fetchInitialTokenUsage(); | ||||||||||||||||
| return () => { cancelled = true; }; | ||||||||||||||||
| }, [selectedProject, selectedSession?.id, selectedSession?.__provider]); | ||||||||||||||||
|
|
||||||||||||||||
| const visibleMessages = useMemo(() => { | ||||||||||||||||
|
|
||||||||||||||||
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.
Validate
CONTEXT_WINDOWas a positive integer before applying override.At Line 306,
parseInt(process.env.CONTEXT_WINDOW) || 0treats negative values as valid and can emit an invalid budget total.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents