@bastani/atomic 0.9.64-alpha.1 → 0.9.65-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/README.md +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +267 -90
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +26 -0
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/model-routing-constraints.js +1 -1
- package/dist/core/model-routing-constraints.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +9 -2
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +16 -0
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/contracts.d.ts +8 -1
- package/dist/core/tasks/contracts.d.ts.map +1 -1
- package/dist/core/tasks/contracts.js.map +1 -1
- package/dist/core/tasks/heartbeat-notice.d.ts +2 -0
- package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat-notice.js +4 -1
- package/dist/core/tasks/heartbeat-notice.js.map +1 -1
- package/dist/core/tasks/heartbeat.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat.js +1 -0
- package/dist/core/tasks/heartbeat.js.map +1 -1
- package/dist/core/tasks/supervisor.d.ts.map +1 -1
- package/dist/core/tasks/supervisor.js +6 -0
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/docs/subagents/reference.md +8 -2
- package/docs/subagents.md +1 -1
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -9026,6 +9026,83 @@ import {
|
|
|
9026
9026
|
SessionManager as SessionManager2
|
|
9027
9027
|
} from "@bastani/atomic";
|
|
9028
9028
|
|
|
9029
|
+
// dist/builtin/subagents/src/runs/shared/model-fallback.ts
|
|
9030
|
+
import {
|
|
9031
|
+
eligiblePair as eligiblePair2,
|
|
9032
|
+
errorMessage,
|
|
9033
|
+
isRetryableModelFailure,
|
|
9034
|
+
modelFailureMessage,
|
|
9035
|
+
normalizeModelFailureSignal,
|
|
9036
|
+
ranOnModelLine
|
|
9037
|
+
} from "@bastani/atomic";
|
|
9038
|
+
import { getSupportedThinkingLevels } from "@bastani/pi-ai/compat";
|
|
9039
|
+
function modelConstraintsFallbackGate(constraints) {
|
|
9040
|
+
const applicable = constraints.filter((constraint) => constraint !== undefined);
|
|
9041
|
+
if (applicable.length === 0)
|
|
9042
|
+
return;
|
|
9043
|
+
return (model, effort) => {
|
|
9044
|
+
const levels = model.reasoning ? getSupportedThinkingLevels(model) : [null];
|
|
9045
|
+
return levels.some((level) => !(model.reasoning && effort !== undefined && level !== effort) && eligiblePair2(model, { model: `${model.provider}/${model.id}`, effort: level }, applicable));
|
|
9046
|
+
};
|
|
9047
|
+
}
|
|
9048
|
+
function launchRequestedModel(agent, options) {
|
|
9049
|
+
if (options.requestedModel)
|
|
9050
|
+
return options.requestedModel;
|
|
9051
|
+
const named = options.modelOverride ?? agent?.model;
|
|
9052
|
+
return named && named !== "auto" ? named : options.currentModel;
|
|
9053
|
+
}
|
|
9054
|
+
function resultRanOnLine(result) {
|
|
9055
|
+
return ranOnModelLine({
|
|
9056
|
+
kind: "agent",
|
|
9057
|
+
model: taskRecordModel(result.model),
|
|
9058
|
+
requestedModel: result.requestedModel
|
|
9059
|
+
});
|
|
9060
|
+
}
|
|
9061
|
+
function applyFallbackThinkingLevel(model, thinkingLevel) {
|
|
9062
|
+
if (!thinkingLevel || !THINKING_LEVELS.some((level) => level === thinkingLevel))
|
|
9063
|
+
return model;
|
|
9064
|
+
const { thinkingSuffix } = splitKnownThinkingSuffix(model);
|
|
9065
|
+
return thinkingSuffix ? model : `${model}:${thinkingLevel}`;
|
|
9066
|
+
}
|
|
9067
|
+
function resolveModelCandidate(model, availableModels, preferredProvider) {
|
|
9068
|
+
if (!model)
|
|
9069
|
+
return;
|
|
9070
|
+
if (model.includes("/"))
|
|
9071
|
+
return model;
|
|
9072
|
+
if (!availableModels || availableModels.length === 0)
|
|
9073
|
+
return model;
|
|
9074
|
+
const { baseModel, thinkingSuffix } = splitKnownThinkingSuffix(model);
|
|
9075
|
+
const matches = availableModels.filter((entry) => entry.id === baseModel);
|
|
9076
|
+
if (preferredProvider) {
|
|
9077
|
+
const preferredMatch = matches.find((entry) => entry.provider === preferredProvider);
|
|
9078
|
+
if (preferredMatch)
|
|
9079
|
+
return `${preferredMatch.fullId}${thinkingSuffix}`;
|
|
9080
|
+
}
|
|
9081
|
+
if (matches.length !== 1)
|
|
9082
|
+
return model;
|
|
9083
|
+
return `${matches[0].fullId}${thinkingSuffix}`;
|
|
9084
|
+
}
|
|
9085
|
+
function buildModelCandidates(primaryModel, fallbackModels, availableModels, preferredProvider, currentModel, fallbackThinkingLevels) {
|
|
9086
|
+
const seen = new Set;
|
|
9087
|
+
const candidates = [];
|
|
9088
|
+
const fallbackEntries = (fallbackModels ?? []).map((model, index) => applyFallbackThinkingLevel(model, fallbackThinkingLevels?.[index]));
|
|
9089
|
+
for (const raw of [primaryModel, ...fallbackEntries, currentModel]) {
|
|
9090
|
+
if (!raw)
|
|
9091
|
+
continue;
|
|
9092
|
+
const normalized = resolveModelCandidate(raw.trim(), availableModels, preferredProvider);
|
|
9093
|
+
if (!normalized || seen.has(normalized))
|
|
9094
|
+
continue;
|
|
9095
|
+
seen.add(normalized);
|
|
9096
|
+
candidates.push(normalized);
|
|
9097
|
+
}
|
|
9098
|
+
return candidates;
|
|
9099
|
+
}
|
|
9100
|
+
function currentModelFullId(model) {
|
|
9101
|
+
if (!model)
|
|
9102
|
+
return;
|
|
9103
|
+
return `${String(model.provider)}/${model.id}`;
|
|
9104
|
+
}
|
|
9105
|
+
|
|
9029
9106
|
// dist/builtin/subagents/src/runs/foreground/run-worktrees.ts
|
|
9030
9107
|
import { existsSync as existsSync9 } from "node:fs";
|
|
9031
9108
|
|
|
@@ -9845,6 +9922,16 @@ function pendingMessagesOfResult(result) {
|
|
|
9845
9922
|
return;
|
|
9846
9923
|
return { messages: result.pendingMessages, taskExpands: result.pendingTaskExpands === true };
|
|
9847
9924
|
}
|
|
9925
|
+
function subagentChildModelChoice(options, agent) {
|
|
9926
|
+
const named = options.requestedModel ?? options.modelOverride ?? agent?.model;
|
|
9927
|
+
const namedModel = options.modelRoute || options.runsNamedModel === false || named === "auto" ? undefined : named;
|
|
9928
|
+
const requestedModel = launchRequestedModel(agent, options);
|
|
9929
|
+
return {
|
|
9930
|
+
...namedModel ? { namedModel } : {},
|
|
9931
|
+
...requestedModel ? { requestedModel } : {},
|
|
9932
|
+
...options.modelConstraints ? { modelConstraints: options.modelConstraints } : {}
|
|
9933
|
+
};
|
|
9934
|
+
}
|
|
9848
9935
|
function subagentChildInheritance(options) {
|
|
9849
9936
|
return {
|
|
9850
9937
|
...options.currentModel ? { model: options.currentModel } : {},
|
|
@@ -10167,58 +10254,6 @@ function sharedAutoGroupForSet(setGroup, items) {
|
|
|
10167
10254
|
return needsAuto ? randomUUID() : undefined;
|
|
10168
10255
|
}
|
|
10169
10256
|
|
|
10170
|
-
// dist/builtin/subagents/src/runs/shared/model-fallback.ts
|
|
10171
|
-
import {
|
|
10172
|
-
errorMessage,
|
|
10173
|
-
isRetryableModelFailure,
|
|
10174
|
-
modelFailureMessage,
|
|
10175
|
-
normalizeModelFailureSignal
|
|
10176
|
-
} from "@bastani/atomic";
|
|
10177
|
-
function applyFallbackThinkingLevel(model, thinkingLevel) {
|
|
10178
|
-
if (!thinkingLevel || !THINKING_LEVELS.some((level) => level === thinkingLevel))
|
|
10179
|
-
return model;
|
|
10180
|
-
const { thinkingSuffix } = splitKnownThinkingSuffix(model);
|
|
10181
|
-
return thinkingSuffix ? model : `${model}:${thinkingLevel}`;
|
|
10182
|
-
}
|
|
10183
|
-
function resolveModelCandidate(model, availableModels, preferredProvider) {
|
|
10184
|
-
if (!model)
|
|
10185
|
-
return;
|
|
10186
|
-
if (model.includes("/"))
|
|
10187
|
-
return model;
|
|
10188
|
-
if (!availableModels || availableModels.length === 0)
|
|
10189
|
-
return model;
|
|
10190
|
-
const { baseModel, thinkingSuffix } = splitKnownThinkingSuffix(model);
|
|
10191
|
-
const matches = availableModels.filter((entry) => entry.id === baseModel);
|
|
10192
|
-
if (preferredProvider) {
|
|
10193
|
-
const preferredMatch = matches.find((entry) => entry.provider === preferredProvider);
|
|
10194
|
-
if (preferredMatch)
|
|
10195
|
-
return `${preferredMatch.fullId}${thinkingSuffix}`;
|
|
10196
|
-
}
|
|
10197
|
-
if (matches.length !== 1)
|
|
10198
|
-
return model;
|
|
10199
|
-
return `${matches[0].fullId}${thinkingSuffix}`;
|
|
10200
|
-
}
|
|
10201
|
-
function buildModelCandidates(primaryModel, fallbackModels, availableModels, preferredProvider, currentModel, fallbackThinkingLevels) {
|
|
10202
|
-
const seen = new Set;
|
|
10203
|
-
const candidates = [];
|
|
10204
|
-
const fallbackEntries = (fallbackModels ?? []).map((model, index) => applyFallbackThinkingLevel(model, fallbackThinkingLevels?.[index]));
|
|
10205
|
-
for (const raw of [primaryModel, ...fallbackEntries, currentModel]) {
|
|
10206
|
-
if (!raw)
|
|
10207
|
-
continue;
|
|
10208
|
-
const normalized = resolveModelCandidate(raw.trim(), availableModels, preferredProvider);
|
|
10209
|
-
if (!normalized || seen.has(normalized))
|
|
10210
|
-
continue;
|
|
10211
|
-
seen.add(normalized);
|
|
10212
|
-
candidates.push(normalized);
|
|
10213
|
-
}
|
|
10214
|
-
return candidates;
|
|
10215
|
-
}
|
|
10216
|
-
function currentModelFullId(model) {
|
|
10217
|
-
if (!model)
|
|
10218
|
-
return;
|
|
10219
|
-
return `${String(model.provider)}/${model.id}`;
|
|
10220
|
-
}
|
|
10221
|
-
|
|
10222
10257
|
// dist/builtin/subagents/src/runs/foreground/ownerless-children.ts
|
|
10223
10258
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
10224
10259
|
|
|
@@ -10517,6 +10552,7 @@ function findDuplicateParallelOutputPath(input) {
|
|
|
10517
10552
|
|
|
10518
10553
|
// dist/builtin/subagents/src/runs/foreground/task-execution.ts
|
|
10519
10554
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
10555
|
+
import { ranOnModelLine as ranOnModelLine2 } from "@bastani/atomic";
|
|
10520
10556
|
|
|
10521
10557
|
// dist/builtin/subagents/src/runs/foreground/task-output-retention.ts
|
|
10522
10558
|
import { mkdtempSync, readFileSync as readFileSync8, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
@@ -10608,9 +10644,11 @@ function settledOutputsFromResponse(response) {
|
|
|
10608
10644
|
function settledOutputsFromRecords(records) {
|
|
10609
10645
|
return records.flatMap((record) => record.execution.kind === "settled" ? [{ taskId: record.ref.taskId, result: record.execution.result }] : []);
|
|
10610
10646
|
}
|
|
10611
|
-
function settledOutputSection(taskId, label, output) {
|
|
10647
|
+
function settledOutputSection(taskId, label, output, ranOn) {
|
|
10612
10648
|
const truncated = output.shown < output.total ? `, first ${output.shown} shown${output.path ? "; read the full output file for the rest" : ""}` : "";
|
|
10613
10649
|
const lines = [`Output of ${taskId} (${label}, ${output.total} bytes${truncated}):`];
|
|
10650
|
+
if (ranOn)
|
|
10651
|
+
lines.push(ranOn);
|
|
10614
10652
|
if (output.requestedPath)
|
|
10615
10653
|
lines.push(`Requested output: ${output.requestedPath}`);
|
|
10616
10654
|
if (output.saveError)
|
|
@@ -10621,18 +10659,19 @@ function settledOutputSection(taskId, label, output) {
|
|
|
10621
10659
|
return lines.join(`
|
|
10622
10660
|
`);
|
|
10623
10661
|
}
|
|
10624
|
-
async function readSettledOutput(host, settled) {
|
|
10662
|
+
async function readSettledOutput(host, settled, record) {
|
|
10625
10663
|
const output = settled.result.output;
|
|
10626
10664
|
if (!output)
|
|
10627
10665
|
return;
|
|
10628
10666
|
const label = subagentTaskResultLabel(settled.result);
|
|
10667
|
+
const ranOn = ranOnModelLine2(record);
|
|
10629
10668
|
const kept = retainedTaskOutput(output.ownerId, output.taskId);
|
|
10630
10669
|
if (kept) {
|
|
10631
10670
|
return settledOutputSection(settled.taskId, label, {
|
|
10632
10671
|
...kept,
|
|
10633
10672
|
shown: Math.min(kept.totalBytes, INLINE_TASK_OUTPUT_MAX_BYTES),
|
|
10634
10673
|
total: kept.totalBytes
|
|
10635
|
-
});
|
|
10674
|
+
}, ranOn);
|
|
10636
10675
|
}
|
|
10637
10676
|
const unavailable = (reason) => `Output of ${settled.taskId} (${label}) is unavailable: ${reason}`;
|
|
10638
10677
|
const lease = host.resolveTask(settled.taskId);
|
|
@@ -10648,7 +10687,7 @@ async function readSettledOutput(host, settled) {
|
|
|
10648
10687
|
const decoder = new TextDecoder;
|
|
10649
10688
|
const head = page.value.chunks.map((chunk) => decoder.decode(chunk.bytes, { stream: true })).join("") + decoder.decode();
|
|
10650
10689
|
const shown = page.value.chunks.reduce((sum, chunk) => sum + chunk.bytes.byteLength, 0);
|
|
10651
|
-
return settledOutputSection(settled.taskId, label, { head, shown, total: Number(output.byteCount) });
|
|
10690
|
+
return settledOutputSection(settled.taskId, label, { head, shown, total: Number(output.byteCount) }, ranOn);
|
|
10652
10691
|
} catch (error) {
|
|
10653
10692
|
return unavailable(error instanceof Error ? error.message : String(error));
|
|
10654
10693
|
}
|
|
@@ -10656,7 +10695,8 @@ async function readSettledOutput(host, settled) {
|
|
|
10656
10695
|
async function settledTaskOutputText(host, settled) {
|
|
10657
10696
|
if (!host || settled.length === 0)
|
|
10658
10697
|
return "";
|
|
10659
|
-
const
|
|
10698
|
+
const records = ownerTaskRecords(new Set(settled.map((entry) => entry.taskId)), host);
|
|
10699
|
+
const sections = await Promise.all(settled.map((entry) => readSettledOutput(host, entry, records.find((record) => record.ref.taskId === entry.taskId))));
|
|
10660
10700
|
const present = sections.filter((section) => section !== undefined);
|
|
10661
10701
|
return present.length ? `
|
|
10662
10702
|
|
|
@@ -10704,7 +10744,9 @@ async function parallelTaskToolResultWithOutput(response, host) {
|
|
|
10704
10744
|
}
|
|
10705
10745
|
function taskResponseRecords(response, host) {
|
|
10706
10746
|
const outcomes = response.kind === "parallel" ? response.slots.map((slot) => slot.outcome) : [response];
|
|
10707
|
-
|
|
10747
|
+
return ownerTaskRecords(new Set(outcomes.flatMap((outcome) => outcome.kind === "admitted" ? [outcome.observation.taskId] : [])), host);
|
|
10748
|
+
}
|
|
10749
|
+
function ownerTaskRecords(ids, host) {
|
|
10708
10750
|
const watched = host?.watchOwnerTasks();
|
|
10709
10751
|
if (!watched?.ok)
|
|
10710
10752
|
return [];
|
|
@@ -10751,7 +10793,9 @@ async function runAgentTask(input) {
|
|
|
10751
10793
|
const childCwd = input.options.cwd ?? input.cwd;
|
|
10752
10794
|
let childSession = {};
|
|
10753
10795
|
let childLaunch = {};
|
|
10754
|
-
const
|
|
10796
|
+
const agentConfig = input.agents.find((agent) => agent.name === input.agent);
|
|
10797
|
+
const agentSource = agentConfig?.source;
|
|
10798
|
+
const requestedModel = launchRequestedModel(agentConfig, input.options);
|
|
10755
10799
|
const forked = input.forked ?? (input.options.sessionManager !== undefined && input.options.resumeSession !== true);
|
|
10756
10800
|
const recordChildTask = (taskId, state, terminalStatus, heldMessages, launch) => {
|
|
10757
10801
|
const worktree = runWorktreeRecord(input.options.runId, input.options.index ?? 0);
|
|
@@ -10773,7 +10817,8 @@ async function runAgentTask(input) {
|
|
|
10773
10817
|
...terminalStatus ? { terminalStatus } : {},
|
|
10774
10818
|
...heldMessages?.messages.length ? { heldMessages: { taskId, ...heldMessages } } : {},
|
|
10775
10819
|
...launch ? { launch } : heldMessages?.taskExpands && input.options.resumeSession !== true && childSession.childSessionId === undefined ? { launch: subagentChildLaunch(input.task, input.intentTask, input.options) } : {},
|
|
10776
|
-
inherited: subagentChildInheritance(input.options)
|
|
10820
|
+
inherited: subagentChildInheritance(input.options),
|
|
10821
|
+
...subagentChildModelChoice(input.options, agentConfig)
|
|
10777
10822
|
});
|
|
10778
10823
|
};
|
|
10779
10824
|
let dispatched = false;
|
|
@@ -10855,6 +10900,7 @@ ${launch.message}` : input.task,
|
|
|
10855
10900
|
task: input.intentTask ?? input.task,
|
|
10856
10901
|
cwd: input.options.cwd ?? input.cwd,
|
|
10857
10902
|
...input.options.modelRoute ? { routerSelection: input.options.modelRoute.routerSelection } : {},
|
|
10903
|
+
...requestedModel ? { requestedModel } : {},
|
|
10858
10904
|
...input.heartbeatMs === undefined ? {} : { heartbeatMs: input.heartbeatMs }
|
|
10859
10905
|
}, input.operation ?? `${input.options.runId}:${input.options.index ?? 0}`, (context) => {
|
|
10860
10906
|
dispatched = true;
|
|
@@ -11136,6 +11182,7 @@ async function runForegroundParallelTasks(input) {
|
|
|
11136
11182
|
onIntercomDetachCommit: () => intercomDetachController.abort(),
|
|
11137
11183
|
modelOverride: input.modelOverrides[index],
|
|
11138
11184
|
modelRoute: input.modelRoutes?.[index],
|
|
11185
|
+
...task.modelConstraints ? { modelConstraints: task.modelConstraints } : {},
|
|
11139
11186
|
availableModels: input.availableModels,
|
|
11140
11187
|
knownModelProviders: input.knownModelProviders,
|
|
11141
11188
|
resolveCandidateModel: input.resolveCandidateModel,
|
|
@@ -11293,7 +11340,8 @@ function runOwnerlessChild(input) {
|
|
|
11293
11340
|
...terminalStatus ? { terminalStatus } : {},
|
|
11294
11341
|
...held?.messages.length ? { heldMessages: { taskId: launchId, ...held } } : {},
|
|
11295
11342
|
...queuedLaunch ? { launch: queuedLaunch } : held?.taskExpands && input.options.resumeSession !== true && childSession.childSessionId === undefined ? { launch: subagentChildLaunch(input.task, undefined, input.options) } : {},
|
|
11296
|
-
inherited: subagentChildInheritance(input.options)
|
|
11343
|
+
inherited: subagentChildInheritance(input.options),
|
|
11344
|
+
...subagentChildModelChoice(input.options)
|
|
11297
11345
|
});
|
|
11298
11346
|
};
|
|
11299
11347
|
const settled = Promise.withResolvers();
|
|
@@ -11846,7 +11894,7 @@ import {
|
|
|
11846
11894
|
} from "@bastani/atomic-natives";
|
|
11847
11895
|
import {
|
|
11848
11896
|
clampThinkingLevel,
|
|
11849
|
-
getSupportedThinkingLevels
|
|
11897
|
+
getSupportedThinkingLevels as getSupportedThinkingLevels2
|
|
11850
11898
|
} from "@bastani/pi-ai/compat";
|
|
11851
11899
|
|
|
11852
11900
|
// dist/builtin/subagents/src/agents/skills.ts
|
|
@@ -12594,7 +12642,7 @@ function formatStartTimeout(ms) {
|
|
|
12594
12642
|
}
|
|
12595
12643
|
var DEFAULT_THINKING_LEVEL = "medium";
|
|
12596
12644
|
function explicitEffortFor(model, requested, settings) {
|
|
12597
|
-
const supported =
|
|
12645
|
+
const supported = getSupportedThinkingLevels2(model).find((level) => level === requested);
|
|
12598
12646
|
if (supported)
|
|
12599
12647
|
return supported;
|
|
12600
12648
|
return clampThinkingLevel(model, settings.getModelThinkingLevel(model.provider, model.id) ?? settings.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL);
|
|
@@ -12920,12 +12968,50 @@ function messagesSinceLaunch(manager, launchLeafId) {
|
|
|
12920
12968
|
function outputFor(ownMessages) {
|
|
12921
12969
|
return lastNonEmptyAssistantText(ownMessages.filter((message) => message.role === "assistant"));
|
|
12922
12970
|
}
|
|
12923
|
-
function
|
|
12971
|
+
function failedChildCause(ownMessages) {
|
|
12924
12972
|
const ownTurns = ownMessages.flatMap((message) => message.role === "assistant" ? [message] : []);
|
|
12973
|
+
const lastTurn = ownTurns.at(-1);
|
|
12974
|
+
if (lastTurn?.stopReason === "error") {
|
|
12975
|
+
const modelError = lastTurn.errorMessage?.trim() || "the model request failed without an error message";
|
|
12976
|
+
return { cause: modelError, modelError };
|
|
12977
|
+
}
|
|
12925
12978
|
if (ownTurns.some((turn) => turn.stopReason !== "error" && turn.stopReason !== "aborted"))
|
|
12926
12979
|
return;
|
|
12927
12980
|
const errorMessage = ownTurns.findLast((turn) => turn.errorMessage?.trim())?.errorMessage?.trim();
|
|
12928
|
-
return errorMessage || "Child ended without completing an assistant turn of its own.";
|
|
12981
|
+
return { cause: errorMessage || "Child ended without completing an assistant turn of its own." };
|
|
12982
|
+
}
|
|
12983
|
+
function namedModelId(spec) {
|
|
12984
|
+
const named = spec.namedModel ?? "";
|
|
12985
|
+
const resolved = spec.resolveCandidateModel?.(named)?.model;
|
|
12986
|
+
return resolved ? `${resolved.provider}/${resolved.id}` : splitKnownThinkingSuffix(named).baseModel;
|
|
12987
|
+
}
|
|
12988
|
+
var NAMED_MODEL_RULE = "No other model was used: a subagent launched on a named model runs only that model and its agent's fallbackModels that its modelConstraints allow.";
|
|
12989
|
+
function namedModelFailureCause(namedModel, namedId, ranModels, error) {
|
|
12990
|
+
const startedOnNamed = ranModels.length === 0 || splitKnownThinkingSuffix(ranModels[0]).baseModel === namedId;
|
|
12991
|
+
const subject = startedOnNamed ? `Model ${namedModel} failed${ranModels.length > 1 ? `, and so did its fallbacks ${ranModels.slice(1).join(", ")}` : ""}` : `This child continued on ${ranModels[0]} in place of ${namedModel}; ${ranModels.join(", ")} failed`;
|
|
12992
|
+
return [
|
|
12993
|
+
`${subject}: ${error}${/[.!?]$/.test(error) ? "" : "."}`,
|
|
12994
|
+
NAMED_MODEL_RULE,
|
|
12995
|
+
"If the failure is temporary, retry the launch; otherwise launch it on another model."
|
|
12996
|
+
].join(" ");
|
|
12997
|
+
}
|
|
12998
|
+
function assertStartedOnNamedModel(namedModel, started) {
|
|
12999
|
+
const named = splitKnownThinkingSuffix(namedModel).baseModel;
|
|
13000
|
+
const startedId = started ? `${started.provider}/${started.id}` : undefined;
|
|
13001
|
+
if (started && (named.includes("/") ? startedId === named : started.id === named))
|
|
13002
|
+
return;
|
|
13003
|
+
throw new Error(`Model ${namedModel} is not available: it did not resolve to a model this session can run${startedId ? `, and the session would have started on ${startedId} instead` : ""}. ${NAMED_MODEL_RULE}`);
|
|
13004
|
+
}
|
|
13005
|
+
function assertStartModelAllowed(input) {
|
|
13006
|
+
const { spec, gate, model, effort } = input;
|
|
13007
|
+
if (!gate || !model || spec.namedModel !== undefined && input.ownModel === undefined)
|
|
13008
|
+
return;
|
|
13009
|
+
const named = spec.namedModel === undefined ? undefined : spec.resolveCandidateModel?.(spec.namedModel)?.model;
|
|
13010
|
+
if (named?.provider === model.provider && named.id === model.id)
|
|
13011
|
+
return;
|
|
13012
|
+
if (gate(model, effort))
|
|
13013
|
+
return;
|
|
13014
|
+
throw new Error(`Model ${model.provider}/${model.id}${effort ? ` at ${effort} effort` : ""} would run${spec.namedModel ? ` in place of ${spec.namedModel}` : ""}, but the launch's modelConstraints do not allow it. No other model was used.`);
|
|
12929
13015
|
}
|
|
12930
13016
|
function cancelledEnvelope(session, spec, stats, ownMessages) {
|
|
12931
13017
|
return recoverCancelledChildOutput({
|
|
@@ -13281,6 +13367,7 @@ class SubagentControlRuntime {
|
|
|
13281
13367
|
const launchLeafId = sessionManager.getLeafId();
|
|
13282
13368
|
ownMessages = () => messagesSinceLaunch(sessionManager, launchLeafId);
|
|
13283
13369
|
let created;
|
|
13370
|
+
let startGate;
|
|
13284
13371
|
if (admitted.spec.testSession) {
|
|
13285
13372
|
created = { session: createTestSession(sessionManager, admitted.spec) };
|
|
13286
13373
|
} else {
|
|
@@ -13313,6 +13400,14 @@ class SubagentControlRuntime {
|
|
|
13313
13400
|
...explicit && inherited.model ? { thinkingLevel: explicitEffortFor(inherited.model, startEffort, settingsManager) } : {},
|
|
13314
13401
|
...explicit || pinnedFallbacks.some((entry, index) => entry !== fallbackEntries[index]) ? { fallbackModels: pinnedFallbacks } : {}
|
|
13315
13402
|
};
|
|
13403
|
+
startGate = inherited.isFallbackModelAllowed;
|
|
13404
|
+
assertStartModelAllowed({
|
|
13405
|
+
spec: admitted.spec,
|
|
13406
|
+
ownModel: candidate.model ?? admitted.policy.model,
|
|
13407
|
+
gate: inherited.isFallbackModelAllowed,
|
|
13408
|
+
model: inherited.model,
|
|
13409
|
+
effort: explicitEffort.thinkingLevel ?? inherited.thinkingLevel
|
|
13410
|
+
});
|
|
13316
13411
|
const resourceLoader = new DefaultResourceLoader(inProcessChildResourceLoaderOptions({
|
|
13317
13412
|
cwd: admitted.policy.cwd,
|
|
13318
13413
|
agentDir,
|
|
@@ -13357,6 +13452,18 @@ class SubagentControlRuntime {
|
|
|
13357
13452
|
}
|
|
13358
13453
|
clearTimeout(startTimer);
|
|
13359
13454
|
session = created.session;
|
|
13455
|
+
if (!admitted.spec.testSession) {
|
|
13456
|
+
const ownModel = candidate.model ?? admitted.policy.model;
|
|
13457
|
+
if (admitted.spec.namedModel !== undefined && !ownModel)
|
|
13458
|
+
assertStartedOnNamedModel(admitted.spec.namedModel, session.model);
|
|
13459
|
+
assertStartModelAllowed({
|
|
13460
|
+
spec: admitted.spec,
|
|
13461
|
+
ownModel,
|
|
13462
|
+
gate: startGate,
|
|
13463
|
+
model: session.model,
|
|
13464
|
+
effort: session.thinkingLevel
|
|
13465
|
+
});
|
|
13466
|
+
}
|
|
13360
13467
|
const transcriptSession = session;
|
|
13361
13468
|
let observedStreamingMessage;
|
|
13362
13469
|
taskHooks?.bindTranscript?.({
|
|
@@ -13504,7 +13611,8 @@ class SubagentControlRuntime {
|
|
|
13504
13611
|
const sessionFile = session.sessionFile;
|
|
13505
13612
|
const producedMessages = ownMessages();
|
|
13506
13613
|
const output = outputFor(producedMessages);
|
|
13507
|
-
const
|
|
13614
|
+
const failure = termination === undefined ? failedChildCause(producedMessages) : undefined;
|
|
13615
|
+
const noOutput = failure?.modelError !== undefined && admitted.spec.namedModel !== undefined ? namedModelFailureCause(admitted.spec.namedModel, namedModelId(admitted.spec), attemptedModels, failure.modelError) : failure?.cause;
|
|
13508
13616
|
const status = noOutput === undefined ? attemptStatus(termination) : "error";
|
|
13509
13617
|
this.native.publishChildStatus(admitted.identity.path, nativeStatus(status));
|
|
13510
13618
|
this.native.finishChildAttempt(token, nativeStatus(status));
|
|
@@ -13692,9 +13800,11 @@ class SubagentControlRuntime {
|
|
|
13692
13800
|
const thinking = running.currentThinking;
|
|
13693
13801
|
if (model === undefined && thinking === undefined)
|
|
13694
13802
|
return;
|
|
13803
|
+
const requestedModel = running.child.spec.requestedModel;
|
|
13695
13804
|
return {
|
|
13696
13805
|
...model === undefined ? {} : { model },
|
|
13697
|
-
...thinking === undefined ? {} : { thinking }
|
|
13806
|
+
...thinking === undefined ? {} : { thinking },
|
|
13807
|
+
...requestedModel === undefined ? {} : { requestedModel }
|
|
13698
13808
|
};
|
|
13699
13809
|
}
|
|
13700
13810
|
async terminateChildAttempt(running, cause) {
|
|
@@ -14040,7 +14150,7 @@ function progressFor(agent, task, outcome, startedAt) {
|
|
|
14040
14150
|
...outcome.status === "interrupted" && isParentCancellation(outcome.cause) ? { cause: outcome.cause } : {}
|
|
14041
14151
|
};
|
|
14042
14152
|
}
|
|
14043
|
-
function resultFromOutcome(agent, task, outcome, startedAt, artifactPaths) {
|
|
14153
|
+
function resultFromOutcome(agent, task, outcome, startedAt, artifactPaths, requestedModel) {
|
|
14044
14154
|
const status = outcome.status;
|
|
14045
14155
|
const output = outcome.status === "killed" ? "Killed. This child cannot be resumed." : outcome.status === "ok" ? outcome.output : outcome.envelope;
|
|
14046
14156
|
const model = outcome.model;
|
|
@@ -14062,6 +14172,7 @@ function resultFromOutcome(agent, task, outcome, startedAt, artifactPaths) {
|
|
|
14062
14172
|
usage: usageFromStats(outcome.stats),
|
|
14063
14173
|
...model === undefined ? {} : { model },
|
|
14064
14174
|
...thinking === undefined ? {} : { thinking },
|
|
14175
|
+
...requestedModel ? { requestedModel } : {},
|
|
14065
14176
|
..."attemptedModels" in outcome && outcome.attemptedModels?.length ? { attemptedModels: [...outcome.attemptedModels] } : {},
|
|
14066
14177
|
...outcome.skills?.length ? { skills: [...outcome.skills] } : {},
|
|
14067
14178
|
...outcome.skillsWarning ? { skillsWarning: outcome.skillsWarning } : {},
|
|
@@ -14105,6 +14216,13 @@ function noSpawnableCandidatesResult(agent, task, skippedAttempts) {
|
|
|
14105
14216
|
const reason = "No spawnable subagent model candidates after pre-spawn filtering.";
|
|
14106
14217
|
return { ...refusedResult(agent, task, reason), modelAttempts: skippedAttempts };
|
|
14107
14218
|
}
|
|
14219
|
+
function namedModelUnavailableResult(agent, task, namedModel, skipped) {
|
|
14220
|
+
const reasons = skipped.map((attempt) => attempt.error).filter((reason) => reason !== undefined);
|
|
14221
|
+
return {
|
|
14222
|
+
...refusedResult(agent, task, `Model ${namedModel} is not available${reasons.length ? ` (${reasons.join(" ")})` : ""}. No other model was used: a subagent launched on a named model runs only that model and its agent's fallbackModels that its modelConstraints allow.`),
|
|
14223
|
+
modelAttempts: skipped
|
|
14224
|
+
};
|
|
14225
|
+
}
|
|
14108
14226
|
function unknownModelResult(agent, task, candidate, effort, baseModel) {
|
|
14109
14227
|
return refusedResult(agent, task, `Unknown model "${candidate}": "${effort}" is not an effort level (${THINKING_LEVELS.join(", ")}), and no available model is "${baseModel}".`);
|
|
14110
14228
|
}
|
|
@@ -14115,10 +14233,27 @@ async function runSingleInProcess(runtimeCwd, agent, task, options) {
|
|
|
14115
14233
|
if (!statSync9(cwd).isDirectory())
|
|
14116
14234
|
return refusedResult(agent, task, `cwd is not a directory: ${cwd}`);
|
|
14117
14235
|
options.modelRoute?.assertCurrent();
|
|
14236
|
+
const launchModel = options.modelOverride ?? agent.model ?? "";
|
|
14237
|
+
const namesModel = !options.modelRoute && options.runsNamedModel !== false && launchModel !== "" && launchModel !== "auto";
|
|
14238
|
+
const namedModel = namesModel ? options.requestedModel ?? launchModel : undefined;
|
|
14239
|
+
const baseOf = (model) => splitKnownThinkingSuffix(resolveModelCandidate(model, options.availableModels, options.preferredModelProvider) ?? model).baseModel;
|
|
14240
|
+
const namedBase = namedModel === undefined ? undefined : baseOf(namedModel);
|
|
14241
|
+
const continuesOnOther = namedBase !== undefined && baseOf(launchModel) !== namedBase;
|
|
14242
|
+
const fallbackGate = options.modelRoute ? options.modelRoute.allowsModel : modelConstraintsFallbackGate([agent.modelConstraints, options.modelConstraints]);
|
|
14118
14243
|
const seenModels = new Set;
|
|
14119
|
-
const
|
|
14120
|
-
|
|
14121
|
-
|
|
14244
|
+
const fallbackLevels = options.modelRoute?.fallbackModels?.length ? [...options.modelRoute.fallbackModels.map(() => "off"), ...agent.fallbackThinkingLevels ?? []] : agent.fallbackThinkingLevels;
|
|
14245
|
+
const builtCandidates = buildModelCandidates(options.modelOverride ?? agent.model, [
|
|
14246
|
+
...continuesOnOther && namedModel !== undefined ? [namedModel] : [],
|
|
14247
|
+
...options.modelRoute?.fallbackModels ?? [],
|
|
14248
|
+
...agent.fallbackModels ?? []
|
|
14249
|
+
], options.availableModels, options.preferredModelProvider, namesModel ? undefined : options.modelRoute && options.currentModel && options.currentThinkingLevel ? `${options.currentModel}:${options.currentThinkingLevel}` : options.currentModel, continuesOnOther && fallbackLevels ? ["", ...fallbackLevels] : fallbackLevels);
|
|
14250
|
+
const rawCandidates = builtCandidates.filter((candidate) => {
|
|
14251
|
+
if (!options.modelRoute) {
|
|
14252
|
+
if (!fallbackGate || namedBase !== undefined && splitKnownThinkingSuffix(candidate).baseModel === namedBase)
|
|
14253
|
+
return true;
|
|
14254
|
+
const resolved = options.resolveCandidateModel?.(candidate);
|
|
14255
|
+
return resolved === undefined || fallbackGate(resolved.model, resolved.thinkingLevel);
|
|
14256
|
+
}
|
|
14122
14257
|
if (!options.modelRoute.allowsCandidate(candidate, options.modelRoute.routerSelection.effort ?? "off"))
|
|
14123
14258
|
return false;
|
|
14124
14259
|
const { baseModel } = splitKnownThinkingSuffix(candidate);
|
|
@@ -14127,12 +14262,31 @@ async function runSingleInProcess(runtimeCwd, agent, task, options) {
|
|
|
14127
14262
|
seenModels.add(baseModel);
|
|
14128
14263
|
return true;
|
|
14129
14264
|
});
|
|
14130
|
-
|
|
14265
|
+
if (!options.modelRoute && builtCandidates.length > 0 && rawCandidates.length === 0)
|
|
14266
|
+
return refusedResult(agent, task, "No subagent model candidate satisfies the launch's modelConstraints.");
|
|
14267
|
+
let filteredCandidates = filterSpawnableModelCandidates({
|
|
14131
14268
|
candidates: rawCandidates,
|
|
14132
14269
|
availableModels: options.availableModels,
|
|
14133
14270
|
knownModelProviders: options.knownModelProviders,
|
|
14134
14271
|
currentModel: options.currentModel
|
|
14135
14272
|
});
|
|
14273
|
+
const resolveCandidate = options.resolveCandidateModel;
|
|
14274
|
+
if (namesModel && resolveCandidate) {
|
|
14275
|
+
const named = continuesOnOther ? undefined : rawCandidates[0];
|
|
14276
|
+
const namedWord = named ? splitUnknownThinkingSuffix(named) : undefined;
|
|
14277
|
+
if (named && namedWord && !resolveCandidate(named))
|
|
14278
|
+
return unknownModelResult(agent, task, named, namedWord.effort, namedWord.baseModel);
|
|
14279
|
+
const unavailable = filteredCandidates.candidates.filter((entry) => resolveCandidate(entry) === undefined);
|
|
14280
|
+
filteredCandidates = {
|
|
14281
|
+
candidates: filteredCandidates.candidates.filter((entry) => !unavailable.includes(entry)),
|
|
14282
|
+
skippedAttempts: [
|
|
14283
|
+
...filteredCandidates.skippedAttempts,
|
|
14284
|
+
...unavailable.map((entry) => skippedModelAttempt(entry, `Skipped ${entry}: no available model matches it.`))
|
|
14285
|
+
]
|
|
14286
|
+
};
|
|
14287
|
+
if (filteredCandidates.candidates.length === 0)
|
|
14288
|
+
return namedModelUnavailableResult(agent, task, namedModel ?? launchModel, filteredCandidates.skippedAttempts);
|
|
14289
|
+
}
|
|
14136
14290
|
if (rawCandidates.length > 0 && filteredCandidates.candidates.length === 0)
|
|
14137
14291
|
return noSpawnableCandidatesResult(agent, task, filteredCandidates.skippedAttempts);
|
|
14138
14292
|
const listedCandidate = filteredCandidates.candidates[0];
|
|
@@ -14145,7 +14299,7 @@ async function runSingleInProcess(runtimeCwd, agent, task, options) {
|
|
|
14145
14299
|
if (listedCandidate && unknownEffort && options.resolveCandidateModel && !resolvedCandidate)
|
|
14146
14300
|
return unknownModelResult(agent, task, listedCandidate, unknownEffort.effort, unknownEffort.baseModel);
|
|
14147
14301
|
const candidate = resolvedCandidate?.unknownEffort !== undefined && unknownEffort ? unknownEffort.baseModel : listedCandidate;
|
|
14148
|
-
const
|
|
14302
|
+
const requestedModel = launchRequestedModel(agent, options);
|
|
14149
14303
|
const requestedSuffix = splitKnownThinkingSuffix(launchModel).thinkingSuffix.slice(1);
|
|
14150
14304
|
const requestedThinking = options.modelRoute ? undefined : THINKING_LEVELS.find((level) => level === requestedSuffix) ?? (launchModel ? options.resolveCandidateModel?.(launchModel)?.unknownEffort : undefined);
|
|
14151
14305
|
const orchestrationContext = workflowOrchestrationContext(options);
|
|
@@ -14211,8 +14365,10 @@ ${task}`);
|
|
|
14211
14365
|
} : {}
|
|
14212
14366
|
} : undefined,
|
|
14213
14367
|
artifactJsonlPath: options.artifactConfig?.includeJsonl === true ? artifactPaths?.jsonlPath : undefined,
|
|
14214
|
-
...fallbackCandidates.length || options.modelRoute ? { fallbackModels: fallbackCandidates } : {},
|
|
14215
|
-
...
|
|
14368
|
+
...fallbackCandidates.length || options.modelRoute || namesModel ? { fallbackModels: fallbackCandidates } : {},
|
|
14369
|
+
...fallbackGate ? { isFallbackModelAllowed: fallbackGate } : {},
|
|
14370
|
+
...namedModel === undefined ? {} : { namedModel },
|
|
14371
|
+
...requestedModel ? { requestedModel } : {},
|
|
14216
14372
|
onProgress: options.onUpdate ? (progress) => {
|
|
14217
14373
|
const liveProgress = { ...progress, index: options.index ?? 0 };
|
|
14218
14374
|
const liveModel = liveProgress.model ?? candidate;
|
|
@@ -14290,7 +14446,7 @@ ${task}`);
|
|
|
14290
14446
|
detachCleanup();
|
|
14291
14447
|
parentAskCleanup();
|
|
14292
14448
|
running.promise.then(async (continuedOutcome) => {
|
|
14293
|
-
const recovered = resultFromOutcome(agent, task, continuedOutcome, startedAt, artifactPaths);
|
|
14449
|
+
const recovered = resultFromOutcome(agent, task, continuedOutcome, startedAt, artifactPaths, requestedModel);
|
|
14294
14450
|
await control.deliverChildResult({
|
|
14295
14451
|
path: continuedOutcome.path,
|
|
14296
14452
|
status: continuedOutcome.status,
|
|
@@ -14299,6 +14455,7 @@ ${task}`);
|
|
|
14299
14455
|
envelope: continuedOutcome.envelope,
|
|
14300
14456
|
...recovered.model === undefined ? {} : { model: recovered.model },
|
|
14301
14457
|
...recovered.thinking === undefined ? {} : { thinking: recovered.thinking },
|
|
14458
|
+
...requestedModel ? { requestedModel } : {},
|
|
14302
14459
|
sessionFile: continuedOutcome.sessionFile,
|
|
14303
14460
|
timestamp: Date.now(),
|
|
14304
14461
|
artifactsDir: options.artifactsDir
|
|
@@ -14327,6 +14484,7 @@ ${task}`);
|
|
|
14327
14484
|
usage: emptyUsage(),
|
|
14328
14485
|
...continuedModel === undefined ? {} : { model: continuedModel },
|
|
14329
14486
|
...continuedThinking === undefined ? {} : { thinking: continuedThinking },
|
|
14487
|
+
...requestedModel ? { requestedModel } : {},
|
|
14330
14488
|
progress: {
|
|
14331
14489
|
index: options.index ?? 0,
|
|
14332
14490
|
agent: agent.name,
|
|
@@ -14351,7 +14509,7 @@ ${task}`);
|
|
|
14351
14509
|
detachCleanup();
|
|
14352
14510
|
parentAskCleanup();
|
|
14353
14511
|
const outcome = winner.value;
|
|
14354
|
-
const result = resultFromOutcome(agent, task, outcome, startedAt, artifactPaths);
|
|
14512
|
+
const result = resultFromOutcome(agent, task, outcome, startedAt, artifactPaths, requestedModel);
|
|
14355
14513
|
if (options.modelRoute)
|
|
14356
14514
|
result.routerSelection = options.modelRoute.routerSelection;
|
|
14357
14515
|
if (filteredCandidates.skippedAttempts.length)
|
|
@@ -14364,6 +14522,7 @@ ${task}`);
|
|
|
14364
14522
|
envelope: outcome.envelope,
|
|
14365
14523
|
...result.model === undefined ? {} : { model: result.model },
|
|
14366
14524
|
...result.thinking === undefined ? {} : { thinking: result.thinking },
|
|
14525
|
+
...requestedModel ? { requestedModel } : {},
|
|
14367
14526
|
sessionFile: outcome.sessionFile,
|
|
14368
14527
|
timestamp: Date.now(),
|
|
14369
14528
|
artifactsDir: options.artifactsDir
|
|
@@ -14927,13 +15086,13 @@ function workflowStageAcceptsDetachedNotification(ctx) {
|
|
|
14927
15086
|
}
|
|
14928
15087
|
function resultSummaryForIntercom(result) {
|
|
14929
15088
|
const output = getSingleResultOutput(result);
|
|
14930
|
-
|
|
14931
|
-
return output ? `${result.error}
|
|
15089
|
+
const summary = result.status === "error" && result.error ? output ? `${result.error}
|
|
14932
15090
|
|
|
14933
15091
|
Output:
|
|
14934
|
-
${output}` : result.error;
|
|
14935
|
-
|
|
14936
|
-
return
|
|
15092
|
+
${output}` : result.error : output || result.error || "(no output)";
|
|
15093
|
+
const ranOn = resultRanOnLine(result);
|
|
15094
|
+
return ranOn ? `${ranOn}
|
|
15095
|
+
${summary}` : summary;
|
|
14937
15096
|
}
|
|
14938
15097
|
function notifyDetachedForegroundChildExit(input) {
|
|
14939
15098
|
const { pi, runId, index, result } = input;
|
|
@@ -15149,7 +15308,7 @@ async function relaunchChild(deps, ctx, record, hold, release, onReopened, resum
|
|
|
15149
15308
|
const resolveCandidateModel = createCandidateModelResolver(ctx.modelRegistry, inherited.modelProvider);
|
|
15150
15309
|
const ownModel = fresh ? fresh.modelOverride && resolveCandidateModel(fresh.modelOverride)?.model ? fresh.modelOverride : undefined : sessionManager ? ownSessionModelCandidate(sessionManager, record, resolveCandidateModel) : undefined;
|
|
15151
15310
|
const inheritedModel = inherited.model && (!record.inherited || resolveCandidateModel(inherited.model)?.model) ? inherited.model : undefined;
|
|
15152
|
-
if (inherited.model && !inheritedModel && !ownModel && !agent.model && !agent.fallbackModels?.length)
|
|
15311
|
+
if (inherited.model && !inheritedModel && !ownModel && !record.namedModel && !agent.model && !agent.fallbackModels?.length)
|
|
15153
15312
|
return unrestorable(`the model it inherited from its parent when it was launched, ${inherited.model}, is no longer available`);
|
|
15154
15313
|
const childOptions = ctx.getChildSessionOptions?.({ tools: agent.tools });
|
|
15155
15314
|
const supervisorAuthorization = childOptions && !childAllowsIntercom(childOptions) ? undefined : hold?.authorization;
|
|
@@ -15185,7 +15344,10 @@ async function relaunchChild(deps, ctx, record, hold, release, onReopened, resum
|
|
|
15185
15344
|
knownModelProviders: collectKnownModelProviders(ctx.modelRegistry),
|
|
15186
15345
|
resolveCandidateModel,
|
|
15187
15346
|
...inherited.modelProvider ? { preferredModelProvider: inherited.modelProvider } : {},
|
|
15188
|
-
...ownModel ? { modelOverride: ownModel } : {},
|
|
15347
|
+
...ownModel ?? record.namedModel ? { modelOverride: ownModel ?? record.namedModel } : {},
|
|
15348
|
+
...record.namedModel === undefined ? { runsNamedModel: false } : {},
|
|
15349
|
+
...record.requestedModel ? { requestedModel: record.requestedModel } : {},
|
|
15350
|
+
...record.modelConstraints ? { modelConstraints: record.modelConstraints } : {},
|
|
15189
15351
|
...inheritedModel ? { currentModel: inheritedModel } : {},
|
|
15190
15352
|
...inherited.thinkingLevel ? { currentThinkingLevel: inherited.thinkingLevel } : {}
|
|
15191
15353
|
};
|
|
@@ -16026,6 +16188,9 @@ function settledCause(control, path, status) {
|
|
|
16026
16188
|
const cause = control.getDeliveredResult(path)?.cause?.replace(/\s+/g, " ").trim();
|
|
16027
16189
|
return cause || undefined;
|
|
16028
16190
|
}
|
|
16191
|
+
function childModels(control, path) {
|
|
16192
|
+
return control.getChildMetadata(path) ?? control.getDeliveredResult(path);
|
|
16193
|
+
}
|
|
16029
16194
|
function childLines(control, id) {
|
|
16030
16195
|
if (id) {
|
|
16031
16196
|
const path = subagentChildPath(control, id);
|
|
@@ -16035,6 +16200,7 @@ function childLines(control, id) {
|
|
|
16035
16200
|
const delivered = control.getDeliveredResult(path);
|
|
16036
16201
|
const childId = control.childIdOf(path);
|
|
16037
16202
|
const cause = settledCause(control, path, child.status);
|
|
16203
|
+
const ranOn = resultRanOnLine(childModels(control, path) ?? {});
|
|
16038
16204
|
return [
|
|
16039
16205
|
...childId ? [`Id: ${childId}`] : [],
|
|
16040
16206
|
`Child: ${child.path}`,
|
|
@@ -16043,6 +16209,7 @@ function childLines(control, id) {
|
|
|
16043
16209
|
`Depth: ${child.depth}`,
|
|
16044
16210
|
`Status: ${child.status}`,
|
|
16045
16211
|
...cause ? [`Cause: ${cause}`] : [],
|
|
16212
|
+
...ranOn ? [ranOn] : [],
|
|
16046
16213
|
`Residency: ${child.loaded ? "loaded" : "cold"}`,
|
|
16047
16214
|
...delivered?.sessionFile ? [`Session: ${delivered.sessionFile}`] : []
|
|
16048
16215
|
];
|
|
@@ -16050,7 +16217,8 @@ function childLines(control, id) {
|
|
|
16050
16217
|
return control.listChildren().map((child) => {
|
|
16051
16218
|
const childId = control.childIdOf(child.path);
|
|
16052
16219
|
const cause = settledCause(control, child.path, child.status);
|
|
16053
|
-
|
|
16220
|
+
const ranOn = resultRanOnLine(childModels(control, child.path) ?? {});
|
|
16221
|
+
return `${child.path} — ${child.status} (${child.loaded ? "loaded" : "cold"})${childId ? ` · id ${childId}` : ""}${cause ? ` · ${cause}` : ""}${ranOn ? ` · ${ranOn.slice("Model: ".length, -1)}` : ""}`;
|
|
16054
16222
|
});
|
|
16055
16223
|
}
|
|
16056
16224
|
function statusGroup(control, id) {
|
|
@@ -16059,7 +16227,7 @@ function statusGroup(control, id) {
|
|
|
16059
16227
|
parentPath: control.parent.path,
|
|
16060
16228
|
children: canonicalChildren(control).filter((child) => !path || path === control.parent.path || child.path === path).map((child) => {
|
|
16061
16229
|
const delivered = control.getDeliveredResult(child.path);
|
|
16062
|
-
const metadata = control
|
|
16230
|
+
const metadata = childModels(control, child.path);
|
|
16063
16231
|
const childId = control.childIdOf(child.path);
|
|
16064
16232
|
const failure = settledCause(control, child.path, child.status);
|
|
16065
16233
|
return {
|
|
@@ -16068,7 +16236,8 @@ function statusGroup(control, id) {
|
|
|
16068
16236
|
...failure === undefined ? {} : { failure },
|
|
16069
16237
|
sessionFile: delivered?.sessionFile,
|
|
16070
16238
|
...metadata?.model === undefined ? {} : { model: metadata.model },
|
|
16071
|
-
...metadata?.thinking === undefined ? {} : { thinking: metadata.thinking }
|
|
16239
|
+
...metadata?.thinking === undefined ? {} : { thinking: metadata.thinking },
|
|
16240
|
+
...metadata?.requestedModel === undefined ? {} : { requestedModel: metadata.requestedModel }
|
|
16072
16241
|
};
|
|
16073
16242
|
})
|
|
16074
16243
|
};
|
|
@@ -17272,7 +17441,11 @@ async function runParallelPath(data, deps) {
|
|
|
17272
17441
|
status: result.status,
|
|
17273
17442
|
error: result.error,
|
|
17274
17443
|
...result.cause ? { cause: result.cause } : {}
|
|
17275
|
-
})), (i, agent) =>
|
|
17444
|
+
})), (i, agent) => {
|
|
17445
|
+
const ranOn = resultRanOnLine(results[i] ?? {});
|
|
17446
|
+
return `=== Task ${i + 1}: ${agent} ===${ranOn ? `
|
|
17447
|
+
${ranOn}` : ""}`;
|
|
17448
|
+
});
|
|
17276
17449
|
const fullContent = worktreeSuffix ? `${childContent}
|
|
17277
17450
|
|
|
17278
17451
|
${worktreeSuffix}` : childContent;
|
|
@@ -17470,6 +17643,7 @@ async function runSinglePath(data, deps) {
|
|
|
17470
17643
|
index: 0,
|
|
17471
17644
|
modelOverride,
|
|
17472
17645
|
modelRoute,
|
|
17646
|
+
...params.modelConstraints ? { modelConstraints: params.modelConstraints } : {},
|
|
17473
17647
|
availableModels,
|
|
17474
17648
|
knownModelProviders,
|
|
17475
17649
|
resolveCandidateModel: createCandidateModelResolver(ctx.modelRegistry, currentProvider),
|
|
@@ -17635,14 +17809,17 @@ async function runSinglePath(data, deps) {
|
|
|
17635
17809
|
details
|
|
17636
17810
|
};
|
|
17637
17811
|
}
|
|
17812
|
+
const ranOn = resultRanOnLine(r);
|
|
17813
|
+
const withRanOn = (text) => ranOn ? `${ranOn}
|
|
17814
|
+
${text}` : text;
|
|
17638
17815
|
if (r.status === "error")
|
|
17639
17816
|
return {
|
|
17640
|
-
content: [{ type: "text", text: formatFailedSingleRunOutput(r, finalizedOutput.displayOutput) }],
|
|
17817
|
+
content: [{ type: "text", text: withRanOn(formatFailedSingleRunOutput(r, finalizedOutput.displayOutput)) }],
|
|
17641
17818
|
details,
|
|
17642
17819
|
isError: true
|
|
17643
17820
|
};
|
|
17644
17821
|
return {
|
|
17645
|
-
content: [{ type: "text", text: finalizedOutput.displayOutput || "(no output)" }],
|
|
17822
|
+
content: [{ type: "text", text: withRanOn(finalizedOutput.displayOutput || "(no output)") }],
|
|
17646
17823
|
details
|
|
17647
17824
|
};
|
|
17648
17825
|
}
|