fix lint
This commit is contained in:
parent
8303740089
commit
17bab809ac
2 changed files with 10 additions and 15 deletions
|
|
@ -270,10 +270,6 @@ func gatewayCmd(debug bool) error {
|
||||||
}
|
}
|
||||||
provider = newProvider
|
provider = newProvider
|
||||||
|
|
||||||
// Update agent loop provider and models
|
|
||||||
//agentLoop.SetProvider(provider, newCfg)
|
|
||||||
|
|
||||||
cfg = newCfg
|
|
||||||
logger.Info(" ✓ Provider and configuration reloaded successfully (thread-safe)")
|
logger.Info(" ✓ Provider and configuration reloaded successfully (thread-safe)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -395,8 +395,12 @@ func (al *AgentLoop) SetChannelManager(cm *channels.Manager) {
|
||||||
|
|
||||||
// ReloadProviderAndConfig atomically swaps the provider and config with proper synchronization.
|
// ReloadProviderAndConfig atomically swaps the provider and config with proper synchronization.
|
||||||
// It uses a context to allow timeout control from the caller.
|
// It uses a context to allow timeout control from the caller.
|
||||||
// Returns an error if the reload fails or context is cancelled.
|
// Returns an error if the reload fails or context is canceled.
|
||||||
func (al *AgentLoop) ReloadProviderAndConfig(ctx context.Context, provider providers.LLMProvider, cfg *config.Config) error {
|
func (al *AgentLoop) ReloadProviderAndConfig(
|
||||||
|
ctx context.Context,
|
||||||
|
provider providers.LLMProvider,
|
||||||
|
cfg *config.Config,
|
||||||
|
) error {
|
||||||
// Validate inputs
|
// Validate inputs
|
||||||
if provider == nil {
|
if provider == nil {
|
||||||
return fmt.Errorf("provider cannot be nil")
|
return fmt.Errorf("provider cannot be nil")
|
||||||
|
|
@ -405,11 +409,6 @@ func (al *AgentLoop) ReloadProviderAndConfig(ctx context.Context, provider provi
|
||||||
return fmt.Errorf("config cannot be nil")
|
return fmt.Errorf("config cannot be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check context before starting
|
|
||||||
if err := ctx.Err(); err != nil {
|
|
||||||
return fmt.Errorf("context cancelled before reload: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create new registry with updated config and provider
|
// Create new registry with updated config and provider
|
||||||
// Wrap in defer/recover to handle any panics gracefully
|
// Wrap in defer/recover to handle any panics gracefully
|
||||||
var registry *AgentRegistry
|
var registry *AgentRegistry
|
||||||
|
|
@ -434,12 +433,12 @@ func (al *AgentLoop) ReloadProviderAndConfig(ctx context.Context, provider provi
|
||||||
return fmt.Errorf("registry creation failed (nil result)")
|
return fmt.Errorf("registry creation failed (nil result)")
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return fmt.Errorf("context cancelled during registry creation: %w", ctx.Err())
|
return fmt.Errorf("context canceled during registry creation: %w", ctx.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check context again before proceeding
|
// Check context again before proceeding
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return fmt.Errorf("context cancelled after registry creation: %w", err)
|
return fmt.Errorf("context canceled after registry creation: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure shared tools are re-registered on the new registry
|
// Ensure shared tools are re-registered on the new registry
|
||||||
|
|
@ -469,8 +468,8 @@ func (al *AgentLoop) ReloadProviderAndConfig(ctx context.Context, provider provi
|
||||||
case <-time.After(100 * time.Millisecond):
|
case <-time.After(100 * time.Millisecond):
|
||||||
stateful.Close()
|
stateful.Close()
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
// Context cancelled, close immediately but log warning
|
// Context canceled, close immediately but log warning
|
||||||
logger.WarnCF("agent", "Context cancelled during provider cleanup, forcing close",
|
logger.WarnCF("agent", "Context canceled during provider cleanup, forcing close",
|
||||||
map[string]any{"error": ctx.Err()})
|
map[string]any{"error": ctx.Err()})
|
||||||
stateful.Close()
|
stateful.Close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue