Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(agent): let omp (Oh-My-Pi) agents set a thinking level (MUL-7412) (#8464)

Bohan Jiangc923ace620b3
diff --git a/packages/views/agents/components/inspector/thinking-prop-row.test.tsx b/packages/views/agents/components/inspector/thinking-prop-row.test.tsx
index 839b1e343b..ce27003176 100644
--- a/packages/views/agents/components/inspector/thinking-prop-row.test.tsx
+++ b/packages/views/agents/components/inspector/thinking-prop-row.test.tsx
@@ -79,6 +79,24 @@ const CODEX_DEFAULT_MODEL: RuntimeModel = {
},
};
+// omp advertises a per-model effort catalog but marks no Default at all, and
+// `omp models --json` sorts by provider/id — so no entry here is the one omp
+// would actually run for an empty model. It also clamps a requested level to
+// whichever model its own default role resolves to, which is why an empty omp
+// model must not preview any entry (MUL-7412).
+const OMP_MODEL: RuntimeModel = {
+ id: "devin/swe-2",
+ label: "SWE-2",
+ thinking: {
+ supported_levels: [
+ { value: "off", label: "Off" },
+ { value: "medium", label: "Medium" },
+ { value: "high", label: "High" },
+ { value: "max", label: "Max" },
+ ],
+ },
+};
+
function listResult(models: RuntimeModel[]): RuntimeModelListRequest {
return {
id: "req-1",
@@ -265,14 +283,62 @@ describe("ThinkingPropRow", () => {
expect(onChange).toHaveBeenCalledWith("");
});
- it("still previews the Default model's levels for an empty non-codex model", async () => {
- // Non-codex providers keep the existing behavior: an empty model previews
- // the flagged Default entry's catalog. Only codex is fenced off, because
- // only its empty-model resolution is config-driven and unknowable here.
+ it("still previews the Default model's levels for an empty model on other providers", async () => {
+ // Other providers keep the existing behavior: an empty model previews the
+ // flagged Default entry's catalog. Only codex and omp are fenced off,
+ // because only their empty-model resolution is unknowable here.
renderRow({ provider: "claude", model: "", value: "" });
await screen.findByText("Thinking");
// CLAUDE_MODEL (Default) advertises Low/Medium/High — the picker shows them.
expect((await screen.findAllByText("Follow CLI config")).length).toBeGreaterThan(0);
});
+
+ it("hides the picker for an empty omp model — no catalog entry is omp's real default (MUL-7412)", async () => {
+ // omp marks no Default and sorts by provider/id, so previewing any entry
+ // would offer levels the model omp actually resolves may silently clamp.
+ mockInitiateListModels.mockResolvedValue(listResult([OMP_MODEL]));
+ mockGetListModelsResult.mockResolvedValue(listResult([OMP_MODEL]));
+ renderRow({ provider: "omp", model: "", value: "" });
+
+ await waitFor(() => {
+ expect(mockInitiateListModels).toHaveBeenCalled();
+ });
+ // findByText, not queryByText: the catalog arrives asynchronously, so a
+ // synchronous "is it absent yet" check passes before the data could have
+ // rendered and would hold even if the row were about to appear. This waits
+ // the full timeout and fails if the row ever shows up.
+ await expect(screen.findByText("Thinking")).rejects.toThrow();
+ // None of the entry's levels leak into the picker.
+ expect(screen.queryByText("Max")).toBeNull();
+ });
+
+ it("previews the catalog for an omp model that is pinned", async () => {
+ // The pinned case is the whole point of the fix: the picker must appear.
+ mockInitiateListModels.mockResolvedValue(listResult([OMP_MODEL]));
+ mockGetListModelsResult.mockResolvedValue(listResult([OMP_MODEL]));
+ renderRow({ provider: "omp", model: "devin/swe-2", value: "" });
+
+ await screen.findByText("Thinking");
+ expect(
+ (await screen.findAllByText("Follow CLI config")).length,
+ ).toBeGreaterThan(0);
+ });
+
+ it("still surfaces a persisted level on an empty omp model so it can be cleared", async () => {
+ mockInitiateListModels.mockResolvedValue(listResult([OMP_MODEL]));
+ mockGetListModelsResult.mockResolvedValue(listResult([OMP_MODEL]));
+ const { onChange } = renderRow({
+ provider: "omp",
+ model: "",
+ value: "max",
+ });
+
+ await screen.findByText("Thinking");
+ expect(await screen.findByText("max")).toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button"));
+ const clearButton = await screen.findByTitle(/Clear the override/i);
+ fireEvent.click(clearButton);
+ expect(onChange).toHaveBeenCalledWith("");
+ });
});
diff --git a/packages/views/agents/components/inspector/thinking-prop-row.tsx b/packages/views/agents/components/inspector/thinking-prop-row.tsx
index 30a0d0ca78..9b8fd5b086 100644
--- a/packages/views/agents/components/inspector/thinking-prop-row.tsx
+++ b/packages/views/agents/components/inspector/thinking-prop-row.tsx
@@ -125,6 +125,13 @@ function pickModelEntry(
// support. Fail closed (no preview): the row hides unless a stale level is
// persisted, in which case it still renders so the orphan can be cleared.
// Mirrors the backend ValidateThinkingLevel. (MUL-4347)
- if (provider === "codex") return undefined;
+ //
+ // omp is fenced off for the same reason with a different cause: its
+ // `omp models --json` catalog marks no default at all and sorts by
+ // provider/id, so `models[0]` is arbitrary — and at task time omp resolves
+ // its own default role model, then clamps the level to what that model
+ // supports. Previewing any entry here would offer a level the real model may
+ // silently lower. (MUL-7412)
+ if (provider === "codex" || provider === "omp") return undefined;
return models.find((m) => m.default) ?? models[0];
}
diff --git a/server/internal/handler/agent.go b/server/internal/handler/agent.go
index a2426a8cce..9e48a35fe7 100644
--- a/server/internal/handler/agent.go
+++ b/server/internal/handler/agent.go
@@ -1456,6 +1456,15 @@ func (h *Handler) CreateAgent(w http.ResponseWriter, r *http.Request) {
return
}
}
+ // An effort with no pinned model is not storable for runtimes that resolve
+ // their own default model out of sight — it would save cleanly, show as set,
+ // and then run at a different level. Reject it here instead of letting the
+ // daemon drop it silently at launch (MUL-7412).
+ if agent.ThinkingLevelRejectedWithoutModel(runtime.Provider) &&
+ req.ThinkingLevel != "" && strings.TrimSpace(req.Model) == "" {
+ writeError(w, http.StatusBadRequest, thinkingNeedsExplicitModelRejection(runtime.Provider))
+ return
+ }
if !agent.IsKnownServiceTier(runtime.Provider, req.ServiceTier) {
writeError(w, http.StatusBadRequest, fmt.Sprintf("service_tier %q is not a recognised value for runtime %q", req.ServiceTier, runtime.Provider))
return
@@ -2100,6 +2109,28 @@ func (h *Handler) UpdateAgent(w http.ResponseWriter, r *http.Request) {
}
}
+ // Same combination check as CreateAgent, but against the state the request
+ // actually lands on: a cleared model with a carried-over effort, or a new
+ // effort on an agent that never had a model, are both the invalid pair. The
+ // caller can always recover by pinning a model or clearing the level, so
+ // this cannot lock an agent out of editing (MUL-7412).
+ if effectiveThinking := effectiveThinkingLevel(params, existing, shouldClearThinkingLevel); effectiveThinking != "" &&
+ strings.TrimSpace(effectiveModelValue(params, existing)) == "" {
+ provider := targetProvider
+ if provider == "" {
+ var ok bool
+ provider, ok = h.resolveAgentProvider(r, existing.WorkspaceID, targetRuntimeID)
+ if !ok {
+ writeError(w, http.StatusInternalServerError, "failed to resolve runtime for thinking_level validation")
+ return
+ }
+ }
+ if agent.ThinkingLevelRejectedWithoutModel(provider) {
+ writeError(w, http.StatusBadRequest, thinkingNeedsExplicitModelRejection(provider))
+ return
+ }
+ }
+
shouldClearServiceTier := false
if req.ServiceTier != nil {
value := *req.ServiceTier
@@ -2319,6 +2350,42 @@ func (h *Handler) resolveAgentProvider(r *http.Request, workspaceID pgtype.UUID,
return rt.Provider, true
}
+// thinkingNeedsExplicitModelRejection is the copy for a level that is valid for
+// the runtime but cannot be stored without a model. It names both ways out so
+// the caller does not have to guess that clearing is allowed.
+func thinkingNeedsExplicitModelRejection(provider string) string {
+ return fmt.Sprintf(
+ "runtime %q resolves its own default model, so a reasoning effort needs an explicit model; set model or pass thinking_level=\"\" to clear",
+ provider,
+ )
+}
+
+// effectiveModelValue is the model the update lands on: the requested value
+// when this request sets one (including an explicit clear), otherwise what the
+// agent already holds.
+func effectiveModelValue(params db.UpdateAgentParams, existing db.Agent) string {
+ if params.Model.Valid {
+ return params.Model.String
+ }
+ return existing.Model.String
+}
+
+// effectiveThinkingLevel is the effort the update lands on. An explicit clear
+// wins over everything; otherwise a value set by this request wins over the
+// stored one, which is carried when the field was omitted.
+func effectiveThinkingLevel(params db.UpdateAgentParams, existing db.Agent, cleared bool) string {
+ if cleared {
+ return ""
+ }
+ if params.ThinkingLevel.Valid {
+ return params.ThinkingLevel.String
+ }
+ if existing.ThinkingLevel.Valid {
+ return existing.ThinkingLevel.String
+ }
+ return ""
+}
+
// thinkingLevelRejection explains why the target runtime will not take this
// thinking_level. Two different failures used to share one sentence: a token
// the runtime's catalog doesn't list, and a runtime with no reasoning control
diff --git a/server/internal/handler/agent_thinking_test.go b/server/internal/handler/agent_thinking_test.go
index bc4c057dca..b4aa0c665a 100644
--- a/server/internal/handler/agent_thinking_test.go
+++ b/server/internal/handler/agent_thinking_test.go
@@ -954,3 +954,189 @@ func createAgentOnRuntimeWithModel(t *testing.T, name, runtimeID, model string)
})
return agentID
}
+
+// createOmpAgent inserts an omp-bound agent with an explicit model and level.
+// Neither shared helper sets both, and the combination is exactly what the
+// clear-the-model case needs.
+func createOmpAgent(t *testing.T, name, runtimeID, model, level string) string {
+ t.Helper()
+ var agentID string
+ var levelArg any
+ if level != "" {
+ levelArg = level
+ }
+ err := testPool.QueryRow(context.Background(), `
+ INSERT INTO agent (
+ workspace_id, name, description, runtime_mode, runtime_config,
+ runtime_id, visibility, max_concurrent_tasks, owner_id,
+ instructions, custom_env, custom_args, model, thinking_level
+ )
+ VALUES ($1, $2, '', 'cloud', '{}'::jsonb, $3, 'private', 1, $4, '', '{}'::jsonb, '[]'::jsonb, $5, $6)
+ RETURNING id
+ `, testWorkspaceID, name, runtimeID, testUserID, model, levelArg).Scan(&agentID)
+ if err != nil {
+ t.Fatalf("create omp agent: %v", err)
+ }
+ t.Cleanup(func() {
+ testPool.Exec(context.Background(), `DELETE FROM agent WHERE id = $1`, agentID)
+ })
+ return agentID
+}
+
+// TestAgent_OmpThinkingLevelRequiresExplicitModel is the API half of MUL-7412.
+// An omp effort with no pinned model must never reach storage: omp resolves its
+// own default role model at task time and clamps the level to what THAT model
+// supports, so a stored level would save cleanly, read back as set, and then run
+// at a different level. Hiding the picker in the inspector does not cover
+// `multica agent create/update` or a direct API call, so the refusal has to live
+// here.
+func TestAgent_OmpThinkingLevelRequiresExplicitModel(t *testing.T) {
+ if testHandler == nil {
+ t.Skip("database not available")
+ }
+ ctx := context.Background()
+ ompRuntimeID := createProviderRuntime(t, "omp")
+
+ t.Cleanup(func() {
+ testPool.Exec(ctx,
+ `DELETE FROM agent WHERE workspace_id = $1 AND name LIKE 'omp-model-gate-%'`,
+ testWorkspaceID,
+ )
+ })
+
+ t.Run("create with a level and no model is 400", func(t *testing.T) {
+ body := map[string]any{
+ "name": "omp-model-gate-nomodel",
+ "runtime_id": ompRuntimeID,
+ "visibility": "private",
+ "max_concurrent_tasks": 1,
+ "thinking_level": "max",
+ }
+ w := httptest.NewRecorder()
+ testHandler.CreateAgent(w, newRequest(http.MethodPost, "/api/agents", body))
+ if w.Code != http.StatusBadRequest {
+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())
+ }
+ // Nothing may persist from a rejected create.
+ var count int
+ if err := testPool.QueryRow(ctx,
+ `SELECT count(*) FROM agent WHERE workspace_id = $1 AND name = 'omp-model-gate-nomodel'`,
+ testWorkspaceID).Scan(&count); err != nil {
+ t.Fatalf("count agents: %v", err)
+ }
+ if count != 0 {
+ t.Errorf("rejected create persisted %d agent(s)", count)
+ }
+ })
+
+ t.Run("create with a level and a pinned model succeeds", func(t *testing.T) {
+ body := map[string]any{
+ "name": "omp-model-gate-pinned",
+ "runtime_id": ompRuntimeID,
+ "visibility": "private",
+ "max_concurrent_tasks": 1,
+ "model": "devin/swe-2",
+ "thinking_level": "max",
+ }
+ w := httptest.NewRecorder()
+ testHandler.CreateAgent(w, newRequest(http.MethodPost, "/api/agents", body))
+ if w.Code != http.StatusCreated {
+ t.Fatalf("expected 201, got %d: %s", w.Code, w.Body.String())
+ }
+ })
+
+ t.Run("create with a whitespace-only model is 400", func(t *testing.T) {
+ // A blank model is stored as non-empty but resolves to nothing, so it
+ // must not be a way around the gate.
+ body := map[string]any{
+ "name": "omp-model-gate-blank",
+ "runtime_id": ompRuntimeID,
+ "visibility": "private",
+ "max_concurrent_tasks": 1,
+ "model": " ",
+ "thinking_level": "max",
+ }
+ w := httptest.NewRecorder()
+ testHandler.CreateAgent(w, newRequest(http.MethodPost, "/api/agents", body))
+ if w.Code != http.StatusBadRequest {
+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())
+ }
+ })
+
+ t.Run("setting a level on a model-less agent is 400", func(t *testing.T) {
+ agentID := createOmpAgent(t, "omp-model-gate-set", ompRuntimeID, "", "")
+ body := map[string]any{"thinking_level": "high"}
+ w := httptest.NewRecorder()
+ req := withURLParam(newRequest(http.MethodPatch, "/api/agents/"+agentID, body), "id", agentID)
+ testHandler.UpdateAgent(w, req)
+ if w.Code != http.StatusBadRequest {
+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())
+ }
+ })
+
+ t.Run("clearing the model while a level persists is 400", func(t *testing.T) {
+ // The level is untouched by this request — the model change alone creates
+ // the invalid pair, so validating only the submitted field would miss it.
+ agentID := createOmpAgent(t, "omp-model-gate-clearmodel", ompRuntimeID, "devin/swe-2", "max")
+ body := map[string]any{"model": ""}
+ w := httptest.NewRecorder()
+ req := withURLParam(newRequest(http.MethodPatch, "/api/agents/"+agentID, body), "id", agentID)
+ testHandler.UpdateAgent(w, req)
+ if w.Code != http.StatusBadRequest {
+ t.Fatalf("expected 400, got %d: %s", w.Code, w.Body.String())
+ }
+ // The stored pair must be untouched by the rejection.
+ var model, level string
+ if err := testPool.QueryRow(ctx,
+ `SELECT coalesce(model, ''), coalesce(thinking_level, '') FROM agent WHERE id = $1`,
+ agentID).Scan(&model, &level); err != nil {
+ t.Fatalf("read agent: %v", err)
+ }
+ if model != "devin/swe-2" || level != "max" {
+ t.Errorf("rejected update mutated state: model=%q level=%q", model, level)
+ }
+ })
+
+ t.Run("clearing model and level together succeeds", func(t *testing.T) {
+ agentID := createOmpAgent(t, "omp-model-gate-clearboth", ompRuntimeID, "devin/swe-2", "max")
+ body := map[string]any{"model": "", "thinking_level": ""}
+ w := httptest.NewRecorder()
+ req := withURLParam(newRequest(http.MethodPatch, "/api/agents/"+agentID, body), "id", agentID)
+ testHandler.UpdateAgent(w, req)
+ if w.Code != http.StatusOK {
+ t.Fatalf("expected 200, got %d: %s", w.Code, w.Body.String())
+ }
+ })
+
+ t.Run("an unrelated edit on a valid agent still succeeds", func(t *testing.T) {
+ // The gate must not lock an agent out of ordinary edits.
+ agentID := createOmpAgent(t, "omp-model-gate-rename", ompRuntimeID, "devin/swe-2", "max")
+ body := map[string]any{"name": "omp-model-gate-rename-2"}
+ w := httptest.NewRecorder()
+ req := withURLParam(newRequest(http.MethodPatch, "/api/agents/"+agentID, body), "id", agentID)
+ testHandler.UpdateAgent(w, req)
+ if w.Code != http.StatusOK {
+ t.Fatalf("expected 200, got %d: %s", w.Code, w.Body.String())
+ }
+ })
+
+ t.Run("a level with no model is still storable on codex", func(t *testing.T) {
+ // codex shares the execution constraint but is deliberately grandfathered:
+ // agents already hold this pair and the daemon drops the level at launch.
+ // Rejecting it here would block unrelated edits to them. Pinned so the
+ // carve-out is a decision on record rather than an oversight.
+ codexRuntimeID := createCodexProviderRuntime(t)
+ body := map[string]any{
+ "name": "omp-model-gate-codex",
+ "runtime_id": codexRuntimeID,
+ "visibility": "private",
+ "max_concurrent_tasks": 1,
+ "thinking_level": "high",
+ }
+ w := httptest.NewRecorder()
+ testHandler.CreateAgent(w, newRequest(http.MethodPost, "/api/agents", body))
+ if w.Code != http.StatusCreated {
+ t.Fatalf("codex empty-model create: expected 201, got %d: %s", w.Code, w.Body.String())
+ }
+ })
+}
diff --git a/server/pkg/agent/models.go b/server/pkg/agent/models.go
index 7bdc9a987e..fa29f69d7a 100644
--- a/server/pkg/agent/models.go
+++ b/server/pkg/agent/models.go
@@ -1364,13 +1364,17 @@ func discoverOmpModels(ctx context.Context, runtimeCmd Command) ([]Model, error)
// Using the bare id would let omp's internal provider priority ranking pick a
// different backend for the same model id. Provider is kept for UI grouping.
// The dedup key is the selector when present, falling back to provider/id.
+// Model.Thinking comes from the entry's `reasoning`/`thinking` fields — see
+// ompThinkingFromCatalogEntry for omp's own rules about what those mean.
func parseOmpModels(data []byte) ([]Model, error) {
var wrapper struct {
Models []struct {
- ID string `json:"id"`
- Provider string `json:"provider"`
- Selector string `json:"selector"`
- Name string `json:"name"`
+ ID string `json:"id"`
+ Provider string `json:"provider"`
+ Selector string `json:"selector"`
+ Name string `json:"name"`
+ Reasoning bool `json:"reasoning"`
+ Thinking json.RawMessage `json:"thinking"`
} `json:"models"`
}
if err := json.Unmarshal(data, &wrapper); err != nil {
@@ -1404,11 +1408,74 @@ func parseOmpModels(data []byte) ([]Model, error) {
if label == "" {
label = selector
}
- models = append(models, Model{ID: selector, Label: label, Provider: provider})
+ models = append(models, Model{
+ ID: selector,
+ Label: label,
+ Provider: provider,
+ Thinking: ompThinkingFromCatalogEntry(e.Reasoning, e.Thinking),
+ })
}
return models, nil
}
+// ompThinkingFromCatalogEntry maps one `omp models --json` entry's reasoning
+// metadata onto Multica's per-model effort catalog.
+//
+// The rules are omp's own, verified against can1357/oh-my-pi v18.2.0:
+//
+// - `models --json` emits `thinking` as a concrete effort array or `null`,
+// never an object — see ModelJson/toModelJson in cli/models-cli.ts.
+// - omp's Effort vocabulary is minimal|low|medium|high|xhigh|max. `off` is
+// NOT an effort and so never appears in that array (catalog/src/effort.ts).
+// - `reasoning: true` with `thinking: null` means "reasons, but exposes no
+// controllable effort dial": getSupportedEfforts documents that exact case.
+// Inferring efforts there would offer levels omp then clamps away, which is
+// the silent mismatch MUL-7412 exists to remove.
+// - `off` is honoured for any model whatever its effort array, because
+// resolveThinkingLevelForModel returns it before clamping runs
+// (coding-agent/src/thinking.ts).
+//
+// So a reasoning model gets `off` plus exactly the efforts the catalog
+// advertised, and nothing inferred. A non-reasoning model gets no picker at
+// all, matching how Multica hides pi's inert `off`-only control.
+//
+// `auto` is deliberately excluded: omp keeps AUTO_THINKING as a session-level
+// sentinel that is explicitly never an Effort or ThinkingLevel and is resolved
+// per turn, so it is not a per-model capability, and providerThinkingEnums
+// rejects it (MUL-7412).
+func ompThinkingFromCatalogEntry(reasoning bool, raw json.RawMessage) *ModelThinking {
+ if !reasoning {
+ return nil
+ }
+ // `off` is always available; the catalog only ever adds efforts on top.
+ advertised := map[string]bool{"off": true}
+ for _, effort := range parseOmpEfforts(raw) {
+ advertised[strings.TrimSpace(effort)] = true
+ }
+ levels := make([]ThinkingLevel, 0, len(piThinkingLevelOrder))
+ for _, value := range piThinkingLevelOrder {
+ if advertised[value] {
+ levels = append(levels, ThinkingLevel{Value: value, Label: piThinkingLevelLabels[value]})
+ }
+ }
+ return &ModelThinking{SupportedLevels: levels}
+}
+
+// parseOmpEfforts reads the effort array out of a catalog entry's `thinking`
+// field. An absent field, `null`, and any shape that is not an array of strings
+// all yield no efforts: a payload we cannot read is not evidence that the model
+// supports anything.
+func parseOmpEfforts(raw json.RawMessage) []string {
+ if len(raw) == 0 {
+ return nil
+ }
+ var efforts []string
+ if err := json.Unmarshal(raw, &efforts); err != nil {
+ return nil
+ }
+ return efforts
+}
+
// discoverHermesModels spins up a throwaway `hermes acp` process,
// drives just enough of the protocol to receive the model list
// advertised in the `session/new` response, and shuts it down. The
diff --git a/server/pkg/agent/omp_test.go b/server/pkg/agent/omp_test.go
index 82014a9eef..65a2ede638 100644
--- a/server/pkg/agent/omp_test.go
+++ b/server/pkg/agent/omp_test.go
@@ -2,9 +2,11 @@ package agent
import (
"context"
+ "errors"
"log/slog"
"path/filepath"
"runtime"
+ "slices"
"strings"
"testing"
"time"
@@ -491,3 +493,308 @@ func TestOmpAndPiRegisterSideBySide(t *testing.T) {
})
}
}
+
+// levelValues flattens a ModelThinking's advertised levels for comparison.
+func levelValues(thinking *ModelThinking) []string {
+ if thinking == nil {
+ return nil
+ }
+ out := make([]string, 0, len(thinking.SupportedLevels))
+ for _, level := range thinking.SupportedLevels {
+ out = append(out, level.Value)
+ }
+ return out
+}
+
+// TestOmpThinkingFromCatalogEntry pins omp's own rules for what a catalog entry
+// means, verified against can1357/oh-my-pi v18.2.0. Two of them are easy to get
+// backwards, and both produce the silent mismatch MUL-7412 exists to remove:
+// `reasoning: true` with no effort array means "no controllable dial" (not
+// "assume the usual levels"), and `off` is honoured for every reasoning model
+// even though it is never a member of the effort array.
+func TestOmpThinkingFromCatalogEntry(t *testing.T) {
+ t.Parallel()
+ tests := []struct {
+ name string
+ reasoning bool
+ thinking string
+ wantLevels []string
+ wantNoPicker bool
+ }{
+ {
+ // The reporter's model in GH #8458. `off` is added on top: omp's
+ // resolveThinkingLevelForModel returns it before clamping runs, so it
+ // really is selectable even though the array never lists it.
+ name: "advertised efforts, plus off",
+ reasoning: true,
+ thinking: `["medium","high","max"]`,
+ wantLevels: []string{"off", "medium", "high", "max"},
+ },
+ {
+ // getSupportedEfforts defines this as "reasons, no controllable effort
+ // surface". Inferring low/medium/high here would offer levels omp then
+ // clamps away.
+ name: "reasoning with null thinking offers only off",
+ reasoning: true,
+ thinking: `null`,
+ wantLevels: []string{"off"},
+ },
+ {
+ name: "reasoning with absent thinking offers only off",
+ reasoning: true,
+ thinking: ``,
+ wantLevels: []string{"off"},
+ },
+ {
+ name: "reasoning with an empty array offers only off",
+ reasoning: true,
+ thinking: `[]`,
+ wantLevels: []string{"off"},
+ },
+ {
+ // No reasoning at all: an off-only control would be inert, so Multica
+ // hides the picker exactly as it does for pi.
+ name: "not a reasoning model has no picker",
+ reasoning: false,
+ thinking: ``,
+ wantNoPicker: true,
+ },
+ {
+ name: "not a reasoning model stays hidden even with efforts listed",
+ reasoning: false,
+ thinking: `["high"]`,
+ wantNoPicker: true,
+ },
+ {
+ // omp keeps `auto` as a session-level sentinel, never a per-model
+ // effort, so it must not reach the picker.
+ name: "auto is never offered",
+ reasoning: true,
+ thinking: `["medium","high","auto"]`,
+ wantLevels: []string{"off", "medium", "high"},
+ },
+ {
+ // Canonical order, not the order omp happened to list.
+ name: "levels come back in canonical order",
+ reasoning: true,
+ thinking: `["max","low","high"]`,
+ wantLevels: []string{"off", "low", "high", "max"},
+ },
+ {
+ // Only tokens Multica knows survive, so a future omp effort cannot
+ // reach the picker before the server's enum accepts it.
+ name: "unknown tokens are dropped",
+ reasoning: true,
+ thinking: `["medium","ultra","hyper"]`,
+ wantLevels: []string{"off", "medium"},
+ },
+ {
+ // `models --json` never emits an object. If one ever appears it is not
+ // evidence of support: fall back to off-only rather than mining it.
+ name: "an unreadable shape proves nothing",
+ reasoning: true,
+ thinking: `{"mode":"effort","efforts":["medium","high","max"]}`,
+ wantLevels: []string{"off"},
+ },
+ }
+ for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
+ got := ompThinkingFromCatalogEntry(tc.reasoning, []byte(tc.thinking))
+ if tc.wantNoPicker {
+ if got != nil {
+ t.Fatalf("ompThinkingFromCatalogEntry = %+v, want nil", got)
+ }
+ return
+ }
+ if got == nil {
+ t.Fatalf("ompThinkingFromCatalogEntry = nil, want levels %v", tc.wantLevels)
+ }
+ if values := levelValues(got); !slices.Equal(values, tc.wantLevels) {
+ t.Errorf("levels = %v, want %v", values, tc.wantLevels)
+ }
+ // omp's `models --json` carries no default level, so we must never
+ // invent one for the picker to preselect.
+ if got.DefaultLevel != "" {
+ t.Errorf("DefaultLevel = %q, want empty", got.DefaultLevel)
+ }
+ for _, level := range got.SupportedLevels {
+ if level.Label == "" {
+ t.Errorf("level %q has an empty label", level.Value)
+ }
+ }
+ })
+ }
+}
+
+// TestParseOmpModelsCarriesThinkingCatalog is the end-to-end catalog assertion:
+// a real `omp models --json` payload must reach Model.Thinking, because that is
+// what the picker renders and what the daemon's per-model guard validates
+// against before injecting --thinking (MUL-7412).
+func TestParseOmpModelsCarriesThinkingCatalog(t *testing.T) {
+ t.Parallel()
+ sample := `{"models":[` +
+ `{"provider":"devin","id":"swe-2","selector":"devin/swe-2","name":"SWE-2","reasoning":true,"thinking":["medium","high","max"]},` +
+ `{"provider":"anthropic","id":"claude-sonnet-5","selector":"anthropic/claude-sonnet-5","name":"Sonnet 5","reasoning":true,"thinking":null},` +
+ `{"provider":"openai","id":"gpt-5","selector":"openai/gpt-5","name":"GPT-5","reasoning":false,"thinking":null}` +
+ `]}`
+ models, err := parseOmpModels([]byte(sample))
+ if err != nil {
+ t.Fatalf("parseOmpModels: %v", err)
+ }
+ if len(models) != 3 {
+ t.Fatalf("expected 3 models, got %d", len(models))
+ }
+ if got := levelValues(models[0].Thinking); !slices.Equal(got, []string{"off", "medium", "high", "max"}) {
+ t.Errorf("devin/swe-2 levels = %v, want [off medium high max]", got)
+ }
+ // Reasons, but omp exposes no effort dial for it: off only, nothing inferred.
+ if got := levelValues(models[1].Thinking); !slices.Equal(got, []string{"off"}) {
+ t.Errorf("anthropic/claude-sonnet-5 levels = %v, want [off]", got)
+ }
+ // No reasoning at all: no picker, rather than an inert one.
+ if models[2].Thinking != nil {
+ t.Errorf("openai/gpt-5 Thinking = %+v, want nil", models[2].Thinking)
+ }
+}
+
+// TestOmpAdvertisedLevelsArePersistable pins the catalog → API contract for omp:
+// every level discovery can advertise must survive the server's Create/Update
+// enum gate. Otherwise the picker offers a level the server 400s on save, which
+// is the mirror image of the MUL-7412 defect.
+func TestOmpAdvertisedLevelsArePersistable(t *testing.T) {
+ t.Parallel()
+ for _, value := range piThinkingLevelOrder {
+ if !IsKnownThinkingValue("omp", value) {
+ t.Errorf("omp advertises %q but the server enum rejects it", value)
+ }
+ }
+ if IsKnownThinkingValue("omp", "auto") {
+ t.Error("omp must not accept `auto`: it is deliberately not exposed (MUL-7412)")
+ }
+}
+
+// TestValidateThinkingLevelOmpEmptyModel pins the omp agent that pins no model:
+// the level must fail closed. omp's catalog marks no default entry, and at task
+// time omp resolves its own default role model and clamps the level to what
+// THAT model supports — so passing a level because some other catalog entry
+// advertises it would let a user save `max` and silently run lower, which is
+// the mismatch MUL-7412 exists to remove.
+func TestValidateThinkingLevelOmpEmptyModel(t *testing.T) {
+ t.Parallel()
+ load := func() (Catalog, error) {
+ return Catalog{Models: []Model{
+ {ID: "devin/swe-2", Label: "SWE-2", Provider: "devin",
+ Thinking: ompThinkingFromCatalogEntry(true, []byte(`["medium","high","max"]`))},
+ {ID: "anthropic/claude-sonnet-5", Label: "Sonnet 5", Provider: "anthropic",
+ Thinking: ompThinkingFromCatalogEntry(true, []byte(`null`))},
+ }}, nil
+ }
+ for _, tc := range []struct {
+ value string
+ want bool
+ }{
+ {value: "", want: true}, // "use the runtime default" is always fine
+ // Advertised by devin/swe-2, but that is not necessarily the model omp
+ // will run, so an unpinned agent must not carry it.
+ {value: "max", want: false},
+ {value: "off", want: false},
+ } {
+ got, err := ValidateThinkingLevelWith(load, "omp", "", tc.value)
+ if err != nil {
+ t.Fatalf("ValidateThinkingLevelWith(omp, \"\", %q): %v", tc.value, err)
+ }
+ if got != tc.want {
+ t.Errorf("ValidateThinkingLevelWith(omp, \"\", %q) = %v, want %v", tc.value, got, tc.want)
+ }
+ }
+ // A pinned model still resolves against that model's own catalog.
+ for _, tc := range []struct {
+ model string
+ value string
+ want bool
+ }{
+ {model: "devin/swe-2", value: "max", want: true},
+ {model: "devin/swe-2", value: "off", want: true},
+ {model: "devin/swe-2", value: "low", want: false},
+ // Reasons with no effort dial: off is real, a concrete effort is not.
+ {model: "anthropic/claude-sonnet-5", value: "off", want: true},
+ {model: "anthropic/claude-sonnet-5", value: "high", want: false},
+ } {
+ got, err := ValidateThinkingLevelWith(load, "omp", tc.model, tc.value)
+ if err != nil {
+ t.Fatalf("ValidateThinkingLevelWith(omp, %q, %q): %v", tc.model, tc.value, err)
+ }
+ if got != tc.want {
+ t.Errorf("ValidateThinkingLevelWith(omp, %q, %q) = %v, want %v", tc.model, tc.value, got, tc.want)
+ }
+ }
+}
+
+// TestValidateThinkingLevelOmpEmptyModelIsDeterministic pins the ORDER of the
+// empty-model rejection, not just its result. The check must happen before any
+// catalog read: on a discovery error the daemon's guard passes the level through
+// to the CLI, so an omp agent with no pinned model would still have shipped an
+// effort omp resolves against a different model. Asserting the loader is never
+// called is the only way to pin that ordering — a test that merely returns false
+// would pass with the check on either side of the load.
+func TestValidateThinkingLevelOmpEmptyModelIsDeterministic(t *testing.T) {
+ t.Parallel()
+ called := false
+ failing := func() (Catalog, error) {
+ called = true
+ return Catalog{}, errors.New("omp discovery failed")
+ }
+ got, err := ValidateThinkingLevelWith(failing, "omp", "", "max")
+ if err != nil {
+ t.Fatalf("ValidateThinkingLevelWith(omp, \"\", max) returned error %v, want a deterministic false", err)
+ }
+ if got {
+ t.Error("ValidateThinkingLevelWith(omp, \"\", max) = true, want false")
+ }
+ if called {
+ t.Error("catalog loader was called; the empty-model rejection must precede discovery")
+ }
+ // The empty "use the runtime default" sentinel still short-circuits ahead of
+ // everything, so it must not reach the loader either.
+ called = false
+ got, err = ValidateThinkingLevelWith(failing, "omp", "", "")
+ if err != nil || !got {
+ t.Errorf("ValidateThinkingLevelWith(omp, \"\", \"\") = (%v, %v), want (true, nil)", got, err)
+ }
+ if called {
+ t.Error("empty thinking level must not trigger discovery")
+ }
+}
+
+// TestThinkingRequiresExplicitModelPredicates pins which providers need a pinned
+// model, and the narrower set whose invalid combination the API refuses to store.
+// codex is deliberately in the first set only: agents already hold an effort with
+// an empty model, so 400ing that pair would block unrelated edits to them.
+func TestThinkingRequiresExplicitModelPredicates(t *testing.T) {
+ t.Parallel()
+ for _, tc := range []struct {
+ provider string
+ needsModel bool
+ rejectedAtAPI bool
+ }{
+ {provider: "omp", needsModel: true, rejectedAtAPI: true},
+ {provider: "codex", needsModel: true, rejectedAtAPI: false},
+ {provider: "pi", needsModel: false, rejectedAtAPI: false},
+ {provider: "claude", needsModel: false, rejectedAtAPI: false},
+ {provider: "opencode", needsModel: false, rejectedAtAPI: false},
+ {provider: "", needsModel: false, rejectedAtAPI: false},
+ } {
+ if got := ThinkingRequiresExplicitModel(tc.provider); got != tc.needsModel {
+ t.Errorf("ThinkingRequiresExplicitModel(%q) = %v, want %v", tc.provider, got, tc.needsModel)
+ }
+ if got := ThinkingLevelRejectedWithoutModel(tc.provider); got != tc.rejectedAtAPI {
+ t.Errorf("ThinkingLevelRejectedWithoutModel(%q) = %v, want %v", tc.provider, got, tc.rejectedAtAPI)
+ }
+ // The API-level refusal is a subset: anything it rejects must also be a
+ // provider that genuinely needs a pinned model.
+ if ThinkingLevelRejectedWithoutModel(tc.provider) && !ThinkingRequiresExplicitModel(tc.provider) {
+ t.Errorf("provider %q is rejected at the API but does not require an explicit model", tc.provider)
+ }
+ }
+}
diff --git a/server/pkg/agent/thinking.go b/server/pkg/agent/thinking.go
index 7ee0594f6a..1375575477 100644
--- a/server/pkg/agent/thinking.go
+++ b/server/pkg/agent/thinking.go
@@ -648,6 +648,8 @@ func catalogLoader(ctx context.Context, providerType string, cmd Command) func()
// "unknown model → reject" (the misjudgement flagged in an earlier
// review). opencode has no single default, so it accepts a level any
// advertised model supports.
+// - omp: fails closed for the same reason by a different route — see
+// ThinkingRequiresExplicitModel.
//
// The lookup goes through ListModels so it sees the *current* CLI
// catalog (including dynamic discovery for codex), not just a static
@@ -673,11 +675,12 @@ func ValidateThinkingLevelWith(loadCatalog func() (Catalog, error), providerType
if value == "" {
return true, nil
}
- // Codex empty-model fail-closed (see doc comment). Checked before the
- // catalog load so the outcome is deterministic even when discovery would
- // error — an errored lookup makes the daemon pass the level through, which
- // is exactly what we must NOT do for an unresolved codex model.
- if model == "" && providerType == "codex" {
+ // Empty-model fail-closed, checked BEFORE the catalog load so the outcome is
+ // deterministic even when discovery would error. That ordering is the whole
+ // point: on a lookup error the daemon passes the level through to the CLI
+ // (see its thinking_level guard), which is exactly what must not happen for
+ // a provider whose effective model we cannot know.
+ if model == "" && ThinkingRequiresExplicitModel(providerType) {
return false, nil
}
catalog, err := loadCatalog()
@@ -698,6 +701,9 @@ func ValidateThinkingLevelWith(loadCatalog func() (Catalog, error), providerType
}
}
if target == "" {
+ // opencode has no single default model, so it accepts a level any
+ // advertised model supports. Providers that instead require a pinned
+ // model never reach here — they were already rejected above.
if providerType == "opencode" {
return anyModelSupportsThinkingValue(models, value), nil
}
@@ -727,6 +733,44 @@ func ValidateThinkingLevelWith(loadCatalog func() (Catalog, error), providerType
return false, nil
}
+// ThinkingRequiresExplicitModel reports whether a provider refuses to carry an
+// effort unless a model is pinned, because its empty-model resolution happens
+// somewhere Multica cannot observe:
+//
+// - codex: the effective model comes from the local config.toml and can be any
+// installed model, so borrowing the catalog's Default entry would green-light
+// levels the configured model may not support (MUL-4347).
+// - omp: its `models --json` catalog marks no default at all and sorts by
+// provider/id, so no entry here is the one that would run. At task time omp
+// resolves its own default role model and clamps the requested level to what
+// THAT model supports, so a level validated against any other entry is not
+// the level that runs (MUL-7412).
+//
+// Both are checked before any catalog read, so discovery failing cannot turn
+// into "pass the level through".
+func ThinkingRequiresExplicitModel(providerType string) bool {
+ switch providerType {
+ case "codex", "omp":
+ return true
+ }
+ return false
+}
+
+// ThinkingLevelRejectedWithoutModel reports whether the API should refuse to
+// STORE an effort that has no pinned model, instead of storing it and leaving
+// the daemon to drop it at launch.
+//
+// Deliberately narrower than ThinkingRequiresExplicitModel. codex shares the
+// execution constraint but predates this check: agents out there already hold an
+// effort alongside an empty model, and 400ing that combination would block
+// unrelated edits to them, so codex stays grandfathered and the daemon keeps
+// dropping the level. omp has no such history — persisting an effort at all was
+// impossible before MUL-7412 — so it is strict from the start and the invalid
+// combination never reaches storage.
+func ThinkingLevelRejectedWithoutModel(providerType string) bool {
+ return providerType == "omp"
+}
+
// ValidateServiceTier reports whether value is advertised by the current
// Codex catalog for the explicit model. An empty value is always valid and
// means "inherit runtime configuration". Codex's "default" sentinel is valid
@@ -832,6 +876,20 @@ var providerThinkingEnums = map[string]map[string]bool{
"xhigh": true,
"max": true,
},
+ // omp (Oh-My-Pi) dispatches to the pi backend (see BuiltinRuntimes), so it
+ // inherits pi's fixed CLI vocabulary; discoverOmpModels narrows it to each
+ // model's advertised efforts before execution. `auto` is deliberately absent
+ // even though omp's --thinking accepts it — see ompThinkingFromCatalogEntry
+ // (MUL-7412).
+ "omp": {
+ "off": true,
+ "minimal": true,
+ "low": true,
+ "medium": true,
+ "high": true,
+ "xhigh": true,
+ "max": true,
+ },
}
// thinkingDynamicCatalogProviders are the runtimes whose effort vocabulary is
diff --git a/server/pkg/agent/thinking_test.go b/server/pkg/agent/thinking_test.go
index 4998560087..dd8d74c199 100644
--- a/server/pkg/agent/thinking_test.go
+++ b/server/pkg/agent/thinking_test.go
@@ -531,6 +531,14 @@ func TestIsKnownThinkingValue(t *testing.T) {
{"pi", "max", true},
{"pi", "ultra", false},
{"pi", "future-level", false},
+ {"omp", "", true},
+ {"omp", "off", true},
+ {"omp", "minimal", true},
+ {"omp", "max", true},
+ // omp's --thinking accepts `auto`, but it picks an effort rather than
+ // being one, so Multica deliberately does not expose it (MUL-7412).
+ {"omp", "auto", false},
+ {"omp", "future-level", false},
{"kimi", "", true},
{"kimi", "low", true},
{"kimi", "max", true},
@@ -577,6 +585,7 @@ func TestThinkingControlSupported(t *testing.T) {
{"dsh", true}, // dynamic catalog from the installed DSH profile
{"opencode", true}, // dynamic variant names from opencode.json
{"pi", true}, // fixed tokens, per-model subset discovered over RPC
+ {"omp", true}, // pi backend identity; per-model subset from `omp models --json`
{"hermes", true}, // jcode applies it; Hermes Agent gets an empty catalog
{"kimi", true}, // dynamic catalog; ACP session/set_config_option applies it
{"qwenpaw", false},
@@ -597,7 +606,7 @@ func TestThinkingControlSupported(t *testing.T) {
// reject a level while claiming the runtime supports one, or vice versa.
func TestThinkingControlSupportedMatchesTokenGate(t *testing.T) {
t.Parallel()
- providers := []string{"claude", "codebuddy", "grok", "codex", "opencode", "pi", "hermes", "kimi", "cursor"}
+ providers := []string{"claude", "codebuddy", "grok", "codex", "opencode", "pi", "omp", "hermes", "kimi", "cursor"}
// "medium" is in every fixed enum and is a well-formed dynamic token, so a
// provider with any reasoning control accepts it.
for _, provider := range providers {