06001697c8
Codex: model/list supportedReasoningEfforts per model, turn/start effort, thread reasoningEffort as the current level. Claude Code: initialize supportedEffortLevels, apply_flag_settings effortLevel at the next turn start. OpenCode v2: model variants via the session model endpoint. chat_effort sets a level; rows and chat_models carry the levels; Codex and Claude levels persist in operator_sessions.chat_effort and are re-applied before every turn.
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
package protocol
|
|
|
|
import "strings"
|
|
|
|
// ChatEffortSelect sets one chat's thinking (reasoning effort) level for its
|
|
// next and later turns. The body is ChatEffortRequest naming a level of the
|
|
// chat's current model; the reply echoes the stored level with the model's
|
|
// levels. A running turn keeps the level it started with.
|
|
const ChatEffortSelect = "chat_effort"
|
|
|
|
// ChatEffort is one thinking level a chat's model accepts, as its harness
|
|
// names it (Codex reasoning efforts, Claude Code effort levels, OpenCode
|
|
// model variants).
|
|
type ChatEffort struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description,omitempty"`
|
|
}
|
|
|
|
// ChatEffortRequest is the chat_effort body, its reply, and the current level
|
|
// a chat_models reply reports. Effort "" means the harness's own default.
|
|
// Efforts and DefaultEffort are reply-only: the levels the chat's current (or
|
|
// saved next-turn) model accepts, and the level the harness uses when none
|
|
// was chosen, when it reports one. No Efforts means the model has no level
|
|
// the harness can set, so no control is offered.
|
|
type ChatEffortRequest struct {
|
|
SessionID string `json:"session_id"`
|
|
Effort string `json:"effort"`
|
|
Efforts []ChatEffort `json:"efforts,omitempty"`
|
|
DefaultEffort string `json:"default_effort,omitempty"`
|
|
}
|
|
|
|
// ChatEffortName is the display name for a level id a harness reports without
|
|
// one: the id in title case, with xhigh spelled out.
|
|
func ChatEffortName(id string) string {
|
|
switch id {
|
|
case "":
|
|
return ""
|
|
case "xhigh":
|
|
return "Extra high"
|
|
}
|
|
return strings.ToUpper(id[:1]) + id[1:]
|
|
}
|
|
|
|
// HasChatEffort reports whether id is one of efforts.
|
|
func HasChatEffort(efforts []ChatEffort, id string) bool {
|
|
for _, effort := range efforts {
|
|
if effort.ID == id {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|