package codex import ( "context" "errors" "strings" "git.a-wan.net/alan/pipelines/internal/protocol" ) // Efforts reports the reasoning efforts model/list advertises for the row's // model (session.Model, already the saved next-turn model) and its default. // A model the catalog does not list, or one without efforts, has none. func (c *Chat) Efforts(ctx context.Context, session protocol.ChatSession) ([]protocol.ChatEffort, string, error) { model := strings.TrimSpace(session.Model) if model == "" { return nil, "", nil } catalog, err := c.catalog(ctx) if err != nil { return nil, "", err } for _, entry := range catalog { if entry.ID == model { return append([]protocol.ChatEffort(nil), entry.Efforts...), entry.DefaultEffort, nil } } return nil, "", nil } // SetEffort records the thread's reasoning effort; it is sent as turn/start's // effort, which Codex keeps for the thread's later turns too. "" sends none. // The server has validated the level against the model's catalog entry. func (c *Chat) SetEffort(_ context.Context, id, effort string) error { if strings.TrimSpace(id) == "" { return errors.New("a Codex thread id is required") } c.mu.Lock() defer c.mu.Unlock() if c.efforts == nil { c.efforts = map[string]string{} } if effort == "" { delete(c.efforts, id) return nil } c.efforts[id] = effort return nil } // applyEffort adds the thread's chosen effort to turn/start params. func (c *Chat) applyEffort(id string, params map[string]any) { c.mu.Lock() effort := c.efforts[id] c.mu.Unlock() if effort != "" { params["effort"] = effort } }