You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5e4b29d
Browse filesBrowse the repository at this point in the historyBrowse files
fix(session): recover orphaned assistant messages on startup (#59)
When the server crashes or restarts while a session is actively
executing tool calls, in-memory session state is lost but the database
retains stale incomplete messages. This leaves sessions permanently
stuck in a 'Thinking' state with no way to recover.
Add Session.recover() that runs during InstanceBootstrap to:
- find assistant messages with no time.completed
- force running/pending tool parts to error status
- mark orphaned messages as completed
- emit bus events so connected frontends update
Closesanomalyco#19023
Co-authored-by: engineer <[email protected]>
// OpenRouter provides inputTokens as the total count of input tokens (including cached).
908
+
// AFAIK other providers (OpenRouter/OpenAI/Gemini etc.) do it the same way e.g. vercel/ai#8794 (comment)
909
+
// Anthropic does it differently though - inputTokens doesn't include cached tokens.
910
+
// It looks like OpenCode's cost calculation assumes all providers return inputTokens the same way Anthropic does (I'm guessing getUsage logic was originally implemented with anthropic), so it's causing incorrect cost calculation for OpenRouter and others.
0 commit comments