What happend:
When the provider is switched to Anthropic mid-task, reinitialize() wipes _session_system_prompts, so has_session_cache() returns False and the action router falls back to the single-turn path. Only the system prompt gets cached for the rest of the task — token cache rate stays around 11–14% instead of 80%+.
Replicate:
- Start a task under any provider.
- Switch provider mid-task via model settings.
- Continue the task. Cache hit rate drops sharply for the rest of the task.
Cause: reinitialize() wipes _session_system_prompts, so has_session_cache() returns False and the action router falls back to the single-turn path instead of the multi-turn KV cache path. Affects all providers: Anthropic loses prefix caching beyond the system prompt, OpenAI/DeepSeek/Grok lose prompt_cache_key routing, BytePlus/Gemini lose session continuity.
Possible fix: Preserve _session_system_prompts across reinitialize() (still wipe provider-specific state like _anthropic_session_messages), and call context_engine.reset_event_stream_sync(call_type) for registered sessions so the next router call seeds the new provider's cache via the "first call" branch.
What happend:
When the provider is switched to Anthropic mid-task, reinitialize() wipes _session_system_prompts, so has_session_cache() returns False and the action router falls back to the single-turn path. Only the system prompt gets cached for the rest of the task — token cache rate stays around 11–14% instead of 80%+.
Replicate:
Cause: reinitialize() wipes _session_system_prompts, so has_session_cache() returns False and the action router falls back to the single-turn path instead of the multi-turn KV cache path. Affects all providers: Anthropic loses prefix caching beyond the system prompt, OpenAI/DeepSeek/Grok lose prompt_cache_key routing, BytePlus/Gemini lose session continuity.
Possible fix: Preserve _session_system_prompts across reinitialize() (still wipe provider-specific state like _anthropic_session_messages), and call context_engine.reset_event_stream_sync(call_type) for registered sessions so the next router call seeds the new provider's cache via the "first call" branch.