返回 DeepSeek-Reasonix
cache_session.go
根目录 / internal / agent / cache_session.go
1 package agent
2
3 import (
4 "context"
5 "reasonix/internal/provider"
6 )
7
8 func (a *Agent) withProviderCacheSession(ctx context.Context) context.Context {
9 // A bound path is stable across resume. Ephemeral/sub-agent sessions use
10 // their own instance identity, never a parent session's inherited header.
11 identity := a.SessionPath()
12 if identity == "" {
13 s := a.Session()
14 s.mu.Lock()
15 if s.cacheSessionID == "" {
16 s.cacheSessionID = provider.NewCacheSessionID()
17 }
18 identity = s.cacheSessionID
19 s.mu.Unlock()
20 }
21 return provider.WithCacheSession(ctx, identity)
22 }
23
23 lines GO