Files
magpie/internal/gui/assets/ompadvisor.js
T
yetone 3f6b1b0c94 agent: omp's advisor turns on with its model, and its review, wait and call-back are set in magpie (#6408, Awad_Yoo on X)
Awad_Yoo wants omp's advisor gated: one model executes, another reviews
only at key points. omp's advisor (src/advisor, advisor/settings.ts) runs
only while advisor.enabled is true, and omp leaves it off, so a model
picked for the advisor role in magpie reviewed nothing.

- A model picked for the advisor role writes advisor.enabled: true when
  the user hasn't set it. The role's reset takes back only what that pick
  wrote (a stash mark); the user's own on or off stays.
- Three Quiet fields write the rest of config.yml's advisor block, as omp
  reads it (omp_advisor.go):
  - advisor_review: off, turn, agent-end (enabled + reviewMode; off keeps
    the mode);
  - advisor_wait: syncBacklog off, "1", "3", "5", strict, written as
    strings, since omp's enum settings take only strings;
  - advisor_wake: continueSeverity nit, concern, blocker.
- GUI: omp's opened row and its panel sheet get three rows (Advisor; Waits
  for its review; Calls a finished agent back on). The last two show only
  while it reviews, and the rows redraw in place. They live in
  ompadvisor.js, imported the first time. The roles square's advisor line
  says " · off" when the advisor is off. Strings in zh, zh-TW, ja and de.
- Core script budget: +717 for what is left in app.js, after the rows
  moved out.
- docs/subsystems/agent-wiring.md has an "omp's advisor" row.

Not magpie's: taking over from the executor after repeated failures of
the same kind. omp has no such setting; "escalate" in its source is only a
note's severity. An omp extension can do it (pi.on("tool_result") with
pi.setModel), and that keeps the session's trace and completed tool
results. Said on the issue.

Run:
- mica-run go test -count=1 ./internal/agent/: ok.
- go vet ./internal/agent/ ./internal/gui/ for darwin, linux (nogui) and
  windows: clean. gofmt -l: nothing.
- internal/gui Go tests: on mote (below).
- GUI, on mote and mica: omp-advisor.test.cjs (new: chromium + webkit;
  1100 and 390px; en, zh, zh-TW, ja, de; panel sheet at 360) passes, as do
  agent-prefs, old-webkit's own check, i18n-en-no-cjk,
  omp-profile-connect and agent-row-disclose.
- Reds that fail the same on a clean worktree at origin/main 743001128
  (45 of 45, the same tests):
  - agent-details-ready: #6373;
  - i18n-keys "a plugin's words are its own": #6422;
  - old-webkit headerpresets.js: #6030;
  - old-webkit :has(): #5919;
  - omp-roles in Chromium, "no roles square": filed as #6432.
- The real omp 18.9.1, in a sandbox HOME (omp config get), reads
  enabled=true, reviewMode=agent-end and syncBacklog=1 as written.

Broken by hand:
- No auto-enable on the pick: TestOmpAdvisorPickTurnsItOn went red.
- No in-place redraw: the panel sheet cases went red, 3 of 3.

Not tried:
- A real omp session with the advisor reviewing.
- continueSeverity needs omp 18.12.1 or later; 18.9.1 doesn't know it.
- A WATCHDOG.yml roster's per-advisor settings aren't shown; omp uses them
  over these.
2026-11-13 13:18:35 +08:00

46 lines
2.5 KiB
JavaScript

// omp's advisor's rows (#6408, Awad_Yoo on X), in an omp's settings:
// whether it reviews and when, how long the agent waits for its review,
// and which note calls a finished agent back, as omp's config.yml has them
// (omp_advisor.go). The last two only once it reviews. app.js imports this
// the first time an omp's settings show (ompAdvisorIn), so it weighs
// nothing on the core.
window.ompAdvisorRows = function (a) {
const val = (k) => a.fields.find((f) => f.key === k)?.value || "";
// the rows answer in place, in a sheet too, as telemetryRow does
const again = () => {
const now = state.agents.find((x) => x.id === a.id);
if (now && rows[0].isConnected) {
rows[0].before(...ompAdvisorRows(now));
for (const r of rows) r.remove();
}
if (view === "agents") renderAgents();
};
const set = (key, v) => api("set", { agent: a.id, field: key, value: v }).then((ns) => {
state = ns;
status(t("Takes effect when {agent} next starts", { agent: a.name }), "ok");
again();
}, (e) => { statusErr(e); again(); });
const row = (name, tip, items, cur, key) => {
const r = el("div", "row pref ag-advisor");
r.dataset.key = key;
const who = el("div", "who");
who.append(el("div", "name", t(name)));
who.title = t(tip);
r.append(who, segs(items.map(([id, label]) => [id, t(label)]), cur, (v) => { if (v !== cur) set(key, v); }));
return r;
};
const review = val("advisor_review") || "off";
const rows = [row("Advisor", "A second model, on the advisor role, reviews the agent's work and sends it notes. A WATCHDOG.yml with advisors sets each one's own review instead",
[["off", "Off"], ["turn", "Every turn"], ["agent-end", "At the end"]], review, "advisor_review")];
if (review === "off") return rows;
// 3 and 5 are omp's too, written by hand or in omp itself
const wait = val("advisor_wait") || "off";
const waits = [["off", "Don't wait"], ["1", "Up to 30s"], ["strict", "Until done"]];
if (wait === "3" || wait === "5") waits.splice(2, 0, [wait, t("{n} behind", { n: wait })]);
rows.push(row("Waits for its review", "Before going on, the agent waits for a review it is owed: up to 30 seconds, or with no limit until every review is in",
waits, wait, "advisor_wait"));
rows.push(row("Calls a finished agent back on", "The least note that brings back an agent that has finished; a lesser one waits for your next message. omp 18.12.1 or later",
[["nit", "Any note"], ["concern", "Concern"], ["blocker", "Blocker"]], val("advisor_wake") || "concern", "advisor_wake"));
return rows;
};