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
[Bug]: Mobile compacts before every send after a provider switch, using the previous provider's stale context usage #41310
I searched existing issues and did not find a duplicate.
I included enough detail to reproduce or investigate the problem.
Area
apps/mobile
Steps to reproduce
Keep idle compaction enabled ("When you return" or "Before the cache expires").
Use a thread with Codex until its context usage goes above 200K tokens (here: 293,703 / 475,000).
Leave it idle for longer than the prompt cache TTL (70 minutes by default).
Switch the same thread to the Claude Agent provider and keep working. Its own context stays well below 200K (here: ~60–85K / 1,000,000).
Send a message from the mobile app.
Send a message to the same thread from the desktop app.
Expected behavior
Mobile decides whether to compact before sending from the context usage of the active provider thread (Claude, ~80K). It does not compact, like desktop.
Actual behavior
Every send from mobile queues a /compact (message id <messageId>:compact, idleCompaction: "onReturn", creationSource: "mobile") about 150 ms before the real message. Each send pays for a 20–30 s compaction run, even though the active context is ~80K.
Desktop does not compact when sending to the same thread.
The thread's state DB has two provider threads:
provider
contextUsage
updatedAt
status
codex
293,703 / 475,000
6 days earlier
idle
claudeAgent
68,282 / 1,000,000
current
active
The stale Codex value satisfies the pre-send check: provider is claudeAgent, at least 200K tokens, and older than the cache TTL. So mobile appears to read context usage from the non-active (previous provider) thread, while desktop reads the active one.
The first send right after switching to Claude did not compact, because the Claude provider thread had no contextUsage yet. Every send after that did. Other threads that never went above 200K never compact from mobile, so the threshold works. Only the source of the usage value is wrong.
Possibly related: the mobile pre-send path added in #27935 / #34247 (shouldCompactBeforeSend).
Impact
Minor bug or occasional failure
Version or commit
Mobile app 2.3.0; T3 Code desktop 0.1.11
Environment
Android mobile app; desktop app and server on Windows 11; Codex provider, then Claude Agent provider (claude-opus-5-5, 1M context)
Logs or stack traces
Screenshots, recordings, or supporting files
No response
Workaround
Send from desktop, start a new thread, turn on "Keep full history" for the thread, or set idle compaction to "Never" (which disables it everywhere).
Activity
juliusmarminge commentedon Nov 23, 2026
This is the same problem as #28581, so I'm closing it in favour of that one. If it is different, say how and it will be reopened.