molianyin4227 (Discord #help): models differ, so one compaction size
for every agent fits none; they asked for Codex, Claude Code and Grok
Build to each have their own, falling back to the shared one.
- settings.AgentCompacts[agent] {At, Full} for the agents that write a
compaction window (CompactAgents: codex, claude, grok); Settings.
ForAgent(agent) lays it over CompactAt/FullContext for that agent's
readers only: codexcat.entriesAt, provider codexListed, Claude Code's
writeCompact and desktopPlan, grokModelTables, the route list's
buildModels, Codex's window line (api.go) and Tuned for you
(gui/tune.go, agent/tune.go). A model's or provider's own Compact at
still comes first. An agent with none follows the shared value, so
nothing new is written for it, and an agent outside the three has no
such key and is refused (provider.SetAgentCompact).
- POST /api/settings/agent-compact {agent, own, full, at}; own false
takes the agent's value away. settingsapi.Merge keeps the map.
- GUI: a row "Long conversations in <agent>" under Long conversations,
in the agent's opened row and its sheet: Every agent / Compact at N /
Full window (segs, no select), a size box when Compact at. It lives in
agentcompact.js, imported when the agent's settings hold Long
conversations, then put in synchronously (an async put-in after a
redraw moved the page in chromium: codex-memories-settings' scroll
check). It draws again only when its own values change. i18n in
zh, zh-TW, ja, de.
- Tuned for you's Use on an agent with its own value changes that one,
stashed under tune.long.compact.<agent>; Undo puts it back.
- codex-memories-settings' "no Codex" check counts Long conversations
alone again (:not(.agent-compact)) and waits for the new row.
- docs/subsystems/agent-wiring.md: a row for it.
Core size: app.js 1,311,919 bytes, 109 under origin/main 0ee424e3e
(1,312,028): the two calls are paid for by four comments cut. The core
total is 1,534,045, still over its budget as on main (#5139), 109 less
than main's 1,534,154. No budget raised.
Run at this tree (based on origin/main 0ee424e3e, fetched just before
the commit), all on mote via mote-run:
- go test settings, settingsapi, codexcat; provider/agent/gui with
-run "Compact|Tune|Grok|SettingsSave|CodexWindow|Long": ok.
- New tests broken by hand, each red: ForAgent taken out of codexcat
(TestCodexCatalogCompactAt), grok.go (TestGrokWindowFollowsLong
Conversations), claude.go (TestClaudeCompactAt); tune's per-agent key
turned off (TestTuneAgentOwnLong: "after apply: codex {At:0
Full:true}"); the row's import call taken out of app.js
(agent-compact.test.cjs 4 of 4 red in chromium).
- GUI, chromium + webkit (en/zh/zh-TW/ja/de as each file has, narrow
and wide): agent-compact, agent-prefs, compact-at, compact-one-value,
settings-general, codex-async-compact, codex-compact-held,
codex-memories-settings, context-tune, segs-glide, i18n-keys,
old-webkit: 432 of 432 ok.
- gofmt -l clean; go vet darwin and GOOS=windows on mote, linux with
-tags gtk3 on magpie-desktop (wsl-run): ok.
- TestCoreScriptBudget: red, 1,534,045 > 1,533,802, as on main (#5139),
109 bytes lower than main.
Not tried: real Codex, Claude Code or Grok Build reading the values
(the config writers are unit-tested); the full go test ./... (after
the push). `magpie model compact` has no per-agent flag, and t3code's
route list reads the shared value.
52 lines
2.8 KiB
JavaScript
52 lines
2.8 KiB
JavaScript
// An agent's own Long conversations (molianyin4227 on Discord: models
|
|
// differ, so one size for every agent fits none): Every agent follows the
|
|
// row above, else this agent compacts at its own size or runs to the whole
|
|
// window (settings.AgentCompacts). app.js imports this when an agent's
|
|
// sheet holds Long conversations, so it weighs nothing on the core.
|
|
window.agentCompactFill = function (list, a) {
|
|
const kind = kindOf(a);
|
|
const row = el("div", "row pref agent-compact");
|
|
row.dataset.agent = kind;
|
|
const who = el("div", "who"), box = el("div");
|
|
who.append(el("div", "name", t("Long conversations in {agent}", { agent: a.name })), el("div", "sub", t("Its own size, for models that differ; Every agent follows Long conversations above")));
|
|
row.append(who, box);
|
|
let drawn;
|
|
const draw = () => {
|
|
// the opened row is built before the settings are read; drawn again then,
|
|
// and only when its own values changed, so the page under it holds still
|
|
const s = prefs || {}, own = (s.agentCompacts || {})[kind];
|
|
const key = JSON.stringify([own, s.compactAt]);
|
|
if (key === drawn) return;
|
|
drawn = key;
|
|
const mode = !own ? "all" : own.full ? "full" : "at";
|
|
// a size of its own starts from the one every agent has
|
|
const at = own ? own.at || 0 : s.compactAt || 0;
|
|
const set = (body) => writingPrefs(api("settings/agent-compact", { agent: kind, ...body }))
|
|
.then((ns) => { prefs = ns; renderSettings(); if (row.isConnected) draw(); }).catch(settingsErr);
|
|
const size = contextsText({ "*": at || 272000 });
|
|
const sg = segs([["all", t("Every agent")], ["at", t("Compact at {n}", { n: size.toUpperCase() })], ["full", t("Full window")]], mode,
|
|
(v) => set(v === "all" ? { own: false } : { own: true, full: v === "full", at }));
|
|
const num = input(at && own ? size : "", "272k");
|
|
num.className = "words compact-num";
|
|
num.hidden = mode !== "at";
|
|
num.title = t("Compact at");
|
|
num.setAttribute("aria-label", t("Compact at"));
|
|
num.onchange = () => {
|
|
const r = parseContexts(num.value);
|
|
if (r.error || Object.keys(r.map).some((k) => k !== "*")) return status(t("Compact at: {v} is not a number of tokens like 272k", { v: num.value.trim() }), "err");
|
|
set({ own: true, full: false, at: r.map["*"] || 0 });
|
|
};
|
|
const line = el("div", "compact-at");
|
|
line.append(sg, num);
|
|
box.replaceChildren(line);
|
|
};
|
|
draw();
|
|
list.querySelector(".agent-compact")?.remove();
|
|
const above = list.querySelector("#fullContextRow");
|
|
above ? above.after(row) : list.append(row);
|
|
// every agent's size, in its label, changes when the row above is drawn
|
|
const seen = new MutationObserver(() => row.isConnected ? draw() : seen.disconnect());
|
|
const segsBox = document.getElementById("fullContextSegs");
|
|
if (segsBox) seen.observe(segsBox, { childList: true });
|
|
};
|