Skip to content

Commit ab4b796

Browse files
committed
refactor(agent): de-slop model-family-policy comment boilerplate
1 parent 60eaff2 commit ab4b796

1 file changed

Lines changed: 29 additions & 31 deletions

File tree

‎src/agent/model-family-policy.ts‎

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313

1414
/**
1515
* Per-model-family tuning for the shared directors (main chat director and
16-
* SubAgentDirector). One policy object, resolved once per session/leaf from
17-
* the provider/model — directors stay generic and branch on data, never on
16+
* SubAgentDirector). One policy object, resolved once per session from the
17+
* provider/model — directors stay generic and branch on data, never on
1818
* per-family subclasses.
1919
*/
2020
export interface ModelFamilyPolicy {
@@ -29,7 +29,7 @@ export interface ModelFamilyPolicy {
2929
toolOnlyTurnNudgeAt: number;
3030
/** Ephemeral nudge text injected at toolOnlyTurnNudgeAt. */
3131
wrapUpNudgeText: string;
32-
/** Wall-clock inactivity, in ms, before a silent sub-agent leaf is nudged. */
32+
/** Wall-clock inactivity, in ms, before a silent sub-agent is nudged. */
3333
subAgentStallTimeoutMs: number;
3434
/** Grok's finish-bias residual (withhold from orchestrators; see provider-family.ts). */
3535
applyGrokFinishBias: boolean;
@@ -47,10 +47,10 @@ export interface ModelFamilyPolicy {
4747
*/
4848
toolDisciplineRules?: string;
4949
/**
50-
* Provider-family residual appended once to the assembled leaf system
50+
* Provider-family residual appended once to the assembled sub-agent system
5151
* prompt (CL-8297). Tool-budget text for grok, the XML task_guidance block
5252
* for claude, the narrate-before-tools note for gpt (CL-8310, primary and
53-
* leaf alike).
53+
* sub-agent alike).
5454
* Withheld from orchestrators and appended at the tail so it cannot
5555
* disturb the cached prompt prefix. Undefined for families that need none.
5656
*/
@@ -84,11 +84,11 @@ const DEFAULT_POLICY: Omit<ModelFamilyPolicy, "family"> = {
8484
advertisedToolDeny: [],
8585
};
8686

87-
// Generic 4-line tool-budget residual (CL-8297). Grok leaves get this via
87+
// Generic 4-line tool-budget residual (CL-8297). Grok sub-agents get this via
8888
// promptResidual today; other families leave the seam unfilled until their
8989
// own lanes land. Deliberately free of ceremony lines and family-specific
90-
// routing — pure tool-loop budget. Single-sourced from the versioned
91-
// prompt-variance package (CL-8269); the name stays for existing importers.
90+
// routing — pure tool-loop budget. Source is grokToolBudgetResidual
91+
// (prompt-variance CL-8269); the old name stays for existing importers.
9292
export const GROK_TOOL_BUDGET_RESIDUAL = grokToolBudgetResidual;
9393

9494
// A directly observed 14-turn pure-tool-call session for this family
@@ -107,7 +107,7 @@ const GROK_POLICY: Omit<ModelFamilyPolicy, "family"> = {
107107
subAgentStallTimeoutMs: DEFAULT_POLICY.subAgentStallTimeoutMs,
108108
applyGrokFinishBias: true,
109109
advertisedToolDeny: [],
110-
// Leaf value; the resolver clears it for orchestrators below.
110+
// Sub-agent value; the resolver clears it for orchestrators below.
111111
promptResidual: GROK_TOOL_BUDGET_RESIDUAL,
112112
};
113113

@@ -123,8 +123,8 @@ const KIMI_POLICY: Omit<ModelFamilyPolicy, "family"> = { ...DEFAULT_POLICY };
123123
// and ran out the 8-turn ceiling without finishing. The same run with these
124124
// three rules appended finished in 3 turns on 4.3x fewer input tokens. At
125125
// minimal effort it terminates either way, so the rules earn their keep exactly
126-
// at the rungs where each wasted turn is most expensive. See CL-7869.
127-
// Single-sourced from the versioned prompt-variance package (CL-8269).
126+
// at the rungs where each wasted turn is most expensive. See CL-7869. Source is
127+
// museRow.residual (prompt-variance CL-8269).
128128
const MUSE_TOOL_DISCIPLINE_RULES = museRow.residual;
129129

130130
const MUSE_POLICY: Omit<ModelFamilyPolicy, "family"> = {
@@ -137,21 +137,19 @@ const MUSE_POLICY: Omit<ModelFamilyPolicy, "family"> = {
137137
// pre-plan, verify once), merged into one block with no line twice. The don't
138138
// re-read idea appears exactly once (the "re-open paths" bullet) — it is not
139139
// repeated. Grok-only: detectModelFamily has no glm family, so per the <30min
140-
// rule no GLM row ships here. The text lives here once; exported for
141-
// buildGrokLeafAntiThrashNote (prompts.ts), which returns it verbatim, so the
142-
// prompt carries exactly one copy. This is a different block from the CL-8297
143-
// tool-budget hook (GROK_TOOL_BUDGET_RESIDUAL, surfaced via the
144-
// ModelFamilyPolicy.promptResidual field): grok leaves carry both, each once.
145-
// Single-sourced from the versioned prompt-variance package (CL-8269); the
146-
// name stays for existing importers.
140+
// rule no GLM row ships here. Source is grokRow.residual (prompt-variance
141+
// CL-8269); the old name stays for existing importers. buildGrokLeafAntiThrashNote
142+
// (prompts.ts) returns it verbatim so the prompt carries one copy. This is a
143+
// different block from the CL-8297 tool-budget hook (GROK_TOOL_BUDGET_RESIDUAL,
144+
// surfaced via the ModelFamilyPolicy.promptResidual field): grok sub-agents
145+
// carry both, each once.
147146
export const GROK_PROMPT_RESIDUAL = grokRow.residual;
148147
// Claude (Anthropic) ships one XML residual, not prose: a prose residual did
149148
// nothing, but a single <task_guidance> block cut Sonnet tokens. The block is
150149
// the whole residual — never a full-prompt XML renderer. The text lives here
151150
// (policy owns data); buildClaudeTaskGuidanceNote (prompts.ts) returns it
152-
// verbatim so the prompt carries exactly one copy. Single-sourced from the
153-
// versioned prompt-variance package (CL-8269); the name stays for existing
154-
// importers.
151+
// verbatim so the prompt carries exactly one copy. Source is claudeRow.residual
152+
// (prompt-variance CL-8269); the old name stays for existing importers.
155153
export const CLAUDE_TASK_GUIDANCE_NOTE = claudeRow.residual;
156154

157155
const CLAUDE_POLICY: Omit<ModelFamilyPolicy, "family"> = {
@@ -168,9 +166,8 @@ const CLAUDE_POLICY: Omit<ModelFamilyPolicy, "family"> = {
168166
// Served cells (sol/terra/…) are never named here — CL-8265 characterizes
169167
// them later. Astra is the one exception: forensics (CL-9027) showed the
170168
// gpt-6-astra cell evading the shared threshold guard via trivial argument
171-
// deltas, so it carries its own residual below. Single-sourced from the
172-
// versioned prompt-variance package (CL-8269); the name stays for existing
173-
// importers.
169+
// deltas, so it carries its own residual below. Source is gptRow.residual
170+
// (prompt-variance CL-8269); the old name stays for existing importers.
174171
export const GPT_NARRATE_BEFORE_TOOLS_NOTE = gptRow.residual;
175172

176173
// GPT (Codex / gpt-*) thresholds are provisional: we have no eval
@@ -180,7 +177,7 @@ export const GPT_NARRATE_BEFORE_TOOLS_NOTE = gptRow.residual;
180177
// GPT_NARRATE_BEFORE_TOOLS_NOTE above), not a threshold.
181178
const GPT_POLICY: Omit<ModelFamilyPolicy, "family"> = {
182179
...DEFAULT_POLICY,
183-
// Primary and leaf alike, so unlike the grok finish-bias there is no
180+
// Primary and sub-agent alike, so unlike the grok finish-bias there is no
184181
// orchestrator carve-out: the resolver below returns this as-is.
185182
promptResidual: GPT_NARRATE_BEFORE_TOOLS_NOTE,
186183
};
@@ -196,7 +193,7 @@ export const ASTRA_PROMPT_RESIDUAL = `${GPT_NARRATE_BEFORE_TOOLS_NOTE}\n${astraR
196193

197194
const ASTRA_POLICY: Omit<ModelFamilyPolicy, "family"> = {
198195
...GPT_POLICY,
199-
// Like gpt, primary and leaf alike: no orchestrator carve-out.
196+
// Like gpt, primary and sub-agent alike: no orchestrator carve-out.
200197
promptResidual: ASTRA_PROMPT_RESIDUAL,
201198
};
202199

@@ -210,7 +207,7 @@ export function resolveModelFamilyPolicy(input: {
210207
switch (family) {
211208
case "grok": {
212209
const policy = { family, ...GROK_POLICY };
213-
// The finish-bias residual only makes sense on leaf workers, mirroring
210+
// The finish-bias residual only makes sense on sub-agents, mirroring
214211
// shouldApplyGrokAntiThrash: orchestrators dispatch other agents rather
215212
// than doing the work directly.
216213
return {
@@ -228,17 +225,18 @@ export function resolveModelFamilyPolicy(input: {
228225
return { family, ...MUSE_POLICY };
229226
case "claude":
230227
// Like the grok finish-bias residual, the task_guidance block only makes
231-
// sense on leaf workers — orchestrators dispatch rather than doing the
228+
// sense on sub-agents — orchestrators dispatch rather than doing the
232229
// work directly, so they resolve to the permissive default (no residual).
233230
return orchestrator
234231
? { family, ...DEFAULT_POLICY }
235232
: { family, ...CLAUDE_POLICY };
236233
case "gpt":
237-
// Primary and leaf alike: no orchestrator carve-out.
234+
// Primary and sub-agent alike: no orchestrator carve-out.
238235
return { family, ...GPT_POLICY };
239236
case "astra":
240-
// Primary and leaf alike, like gpt: no orchestrator carve-out. Generic
241-
// gpt prompts are byte-identical — only astra carries the residual.
237+
// Like gpt, primary and sub-agent alike: no orchestrator carve-out.
238+
// Generic gpt prompts are byte-identical — only astra carries the
239+
// residual.
242240
return { family, ...ASTRA_POLICY };
243241
default:
244242
return { family: "default", ...DEFAULT_POLICY };

0 commit comments

Comments
 (0)