diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 53e63af3b95e8bb4fba6144675d97c3686e78546..5461ae7c5bd3ca055f286635199222ad02facfa5 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -641,14 +641,6 @@ func (a *sessionAgent) Run(ctx context.Context, call SessionAgentCall) (result * currentAssistant.AddFinish(message.FinishReasonCanceled, "User canceled request", "") } else if isHyper && errors.As(err, &providerErr) && providerErr.StatusCode == http.StatusUnauthorized { currentAssistant.AddFinish(message.FinishReasonError, "Unauthorized", `Please re-authenticate with Hyper. You can also run "crush auth" to re-authenticate.`) - if a.notify != nil { - a.notify.Publish(pubsub.CreatedEvent, notify.Notification{ - SessionID: call.SessionID, - SessionTitle: currentSession.Title, - Type: notify.TypeReAuthenticate, - ProviderID: largeModel.ModelCfg.Provider, - }) - } } else if isHyper && errors.As(err, &providerErr) && providerErr.StatusCode == http.StatusPaymentRequired { url := hyper.BaseURL() link := linkStyle.Hyperlink(url, "id=hyper").Render(url) diff --git a/internal/agent/coordinator.go b/internal/agent/coordinator.go index a26aa111eeb8e45a699a6aab90774f04a1aca4bb..860db8b36cb67c43667a0f4a0dfa0a8b1d2e3992 100644 --- a/internal/agent/coordinator.go +++ b/internal/agent/coordinator.go @@ -266,6 +266,12 @@ func (c *coordinator) Run(ctx context.Context, sessionID string, prompt string, if err := c.retryAfterUnauthorized(ctx, providerCfg); err == nil { result, originalErr = run() } + if c.notify != nil && model.ModelCfg.Provider == hyper.Name { + c.notify.Publish(pubsub.CreatedEvent, notify.Notification{ + Type: notify.TypeReAuthenticate, + ProviderID: model.ModelCfg.Provider, + }) + } } if hasLatest && c.runComplete != nil {