mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-08-07 08:24:30 +00:00
feat(agent): adaptive tool timing with slow tool notification
Track per-tool execution time statistics in session metadata. When a tool call exceeds its adaptive threshold (2x historical max, min 120s default), send a direct outbound notification to the user. - ToolTimingMap: parse/serialize/record/threshold from session metadata - StartSlowTimer: fires once per tool call, auto-cancels on completion - Team config: slow_tool toggle (default on, always direct, never leader) - UI: toggle in team settings with i18n (en/vi/zh) - Store: add GetSessionMetadata to session store interface
This commit is contained in:
@@ -142,6 +142,17 @@ func (s *PGSessionStore) SetLabel(key, label string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PGSessionStore) GetSessionMetadata(key string) map[string]string {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
if data, ok := s.cache[key]; ok && data.Metadata != nil {
|
||||
out := make(map[string]string, len(data.Metadata))
|
||||
maps.Copy(out, data.Metadata)
|
||||
return out
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *PGSessionStore) SetSessionMetadata(key string, metadata map[string]string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
@@ -97,6 +97,7 @@ type SessionStore interface {
|
||||
GetCompactionCount(key string) int
|
||||
GetMemoryFlushCompactionCount(key string) int
|
||||
SetMemoryFlushDone(key string)
|
||||
GetSessionMetadata(key string) map[string]string
|
||||
SetSessionMetadata(key string, metadata map[string]string)
|
||||
SetSpawnInfo(key, spawnedBy string, depth int)
|
||||
SetContextWindow(key string, cw int)
|
||||
|
||||
Reference in New Issue
Block a user