agent fix

This commit is contained in:
2026-09-24 12:36:33 +05:30
parent 294fb8ab93
commit bb14445e21
10 changed files with 661 additions and 15 deletions

View File

@@ -97,12 +97,19 @@ type AssistantService interface {
Approve(ctx context.Context, agentName, card string, caller tools.Caller) (AssistantAnswer, error)
// Available reports whether typed questions work at all here.
Available() bool
// Unavailable says WHY not, or "" when it is available. A disabled composer
// with no reason is indistinguishable from a misspelled variable, which is
// how this stayed off without anybody being able to tell.
Unavailable() string
}
type assistantService struct {
registry *tools.Registry
chat utils.Chat
agents map[string]Agent
// Why the model is absent, from config. Carried rather than recomputed so
// the answer the endpoint gives is the one the server actually started with.
why string
// How fast one person may ask. Only questions are limited — approving a
// change the person has already read costs nothing and must not be the call
// that gets refused.
@@ -120,6 +127,19 @@ func NewAssistantService(registry *tools.Registry, chat utils.Chat, agents map[s
func (s *assistantService) Available() bool { return s.chat != nil }
func (s *assistantService) Unavailable() string {
if s.chat != nil {
return ""
}
if s.why != "" {
return s.why
}
return "no assistant model is configured"
}
// SetUnavailableReason records why there is no model, for the status endpoint.
func (s *assistantService) SetUnavailableReason(why string) { s.why = why }
func (s *assistantService) Approve(ctx context.Context, agentName, card string, caller tools.Caller) (AssistantAnswer, error) {
agent, known := s.agents[agentName]
if !known {