feat: add /reload to gateway api and command (#1725)
* feat: add /reload to gateway api and command * prevent duplicate reload request in same time
This commit is contained in:
1 parent
14a28ae93e
commit
2a6ade0fe4
6 files changed
+150
-14
No files matched your search
@@ -49,6 +49,7 @@ type AgentLoop struct {
|
||||
cmdRegistry *commands.Registry
|
||||
mcp mcpRuntime
|
||||
mu sync.RWMutex
|
||||
reloadFunc func() error
|
||||
// Track active requests for safe provider cleanup
|
||||
activeRequests sync.WaitGroup
|
||||
}
|
||||
@@ -498,6 +499,11 @@ func (al *AgentLoop) SetTranscriber(t voice.Transcriber) {
|
||||
al.transcriber = t
|
||||
}
|
||||
|
||||
// SetReloadFunc sets the callback function for triggering config reload.
|
||||
func (al *AgentLoop) SetReloadFunc(fn func() error) {
|
||||
al.reloadFunc = fn
|
||||
}
|
||||
|
||||
var audioAnnotationRe = regexp.MustCompile(`\[(voice|audio)(?::[^\]]*)?\]`)
|
||||
|
||||
// transcribeAudioInMessage resolves audio media refs, transcribes them, and
|
||||
@@ -1931,6 +1937,12 @@ func (al *AgentLoop) buildCommandsRuntime(agent *AgentInstance, opts *processOpt
|
||||
return nil
|
||||
},
|
||||
}
|
||||
rt.ReloadConfig = func() error {
|
||||
if al.reloadFunc == nil {
|
||||
return fmt.Errorf("reload not configured")
|
||||
}
|
||||
return al.reloadFunc()
|
||||
}
|
||||
if agent != nil {
|
||||
rt.GetModelInfo = func() (string, string) {
|
||||
return agent.Model, cfg.Agents.Defaults.Provider
|
||||
|
||||
Reference in new issue
Block a user