@vellumai/assistant 0.8.8-dev.202606061135.a446a08 → 0.8.8-dev.202606061631.10cd5fe
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/openapi.yaml +38 -2
- package/package.json +1 -1
- package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +36 -37
- package/src/__tests__/conversation-runtime-assembly.test.ts +87 -9
- package/src/__tests__/injector-chain.test.ts +70 -7
- package/src/agent/loop.ts +20 -14
- package/src/cli/lib/__tests__/install-from-github.test.ts +248 -2
- package/src/cli/lib/__tests__/plugin-marketplace.test.ts +220 -0
- package/src/cli/lib/__tests__/search-plugins.test.ts +164 -0
- package/src/cli/lib/install-from-github.ts +147 -18
- package/src/cli/lib/plugin-marketplace.ts +197 -0
- package/src/cli/lib/search-plugins.ts +94 -14
- package/src/daemon/conversation-agent-loop.ts +21 -47
- package/src/daemon/conversation-lifecycle.ts +2 -0
- package/src/daemon/conversation-runtime-assembly.ts +57 -70
- package/src/daemon/conversation.ts +5 -5
- package/src/plugins/defaults/memory-retrieval/hooks/post-compact.ts +16 -0
- package/src/plugins/defaults/memory-retrieval/injectors.ts +3 -3
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +50 -10
- package/src/runtime/routes/plugins-routes.ts +67 -6
- package/src/subagent/manager.ts +4 -0
package/openapi.yaml
CHANGED
|
@@ -19457,13 +19457,49 @@ paths:
|
|
|
19457
19457
|
properties:
|
|
19458
19458
|
name:
|
|
19459
19459
|
type: string
|
|
19460
|
-
description:
|
|
19460
|
+
description: Install name. Matches `assistant plugins install <name>`.
|
|
19461
19461
|
path:
|
|
19462
19462
|
type: string
|
|
19463
|
-
description:
|
|
19463
|
+
description:
|
|
19464
|
+
"Human-readable origin: a repo-relative path (`experimental/plugins/<name>`) for first-party plugins or a
|
|
19465
|
+
`github:owner/repo@ref` locator for external ones."
|
|
19466
|
+
description:
|
|
19467
|
+
description: Short description, when known (external entries only today).
|
|
19468
|
+
type: string
|
|
19469
|
+
source:
|
|
19470
|
+
oneOf:
|
|
19471
|
+
- type: object
|
|
19472
|
+
properties:
|
|
19473
|
+
kind:
|
|
19474
|
+
type: string
|
|
19475
|
+
const: first-party
|
|
19476
|
+
required:
|
|
19477
|
+
- kind
|
|
19478
|
+
additionalProperties: false
|
|
19479
|
+
- type: object
|
|
19480
|
+
properties:
|
|
19481
|
+
kind:
|
|
19482
|
+
type: string
|
|
19483
|
+
const: github
|
|
19484
|
+
repo:
|
|
19485
|
+
type: string
|
|
19486
|
+
description: "`owner/repo` of the external plugin repository."
|
|
19487
|
+
path:
|
|
19488
|
+
description: Directory within the repo, when the plugin is not at the root.
|
|
19489
|
+
type: string
|
|
19490
|
+
ref:
|
|
19491
|
+
type: string
|
|
19492
|
+
description: Pinned git ref the plugin is fetched from.
|
|
19493
|
+
required:
|
|
19494
|
+
- kind
|
|
19495
|
+
- repo
|
|
19496
|
+
- ref
|
|
19497
|
+
additionalProperties: false
|
|
19498
|
+
description: "Origin of the match: a first-party in-repo plugin or a whitelisted external one."
|
|
19464
19499
|
required:
|
|
19465
19500
|
- name
|
|
19466
19501
|
- path
|
|
19502
|
+
- source
|
|
19467
19503
|
additionalProperties: false
|
|
19468
19504
|
description: Directory matches, sorted alphabetically by name.
|
|
19469
19505
|
required:
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Verifies that the
|
|
3
|
-
* `
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* long-TTL cache breakpoint on the most recent STABLE message instead
|
|
2
|
+
* Verifies that the `memory-v3-live` cache-anchor signal surfaces on every
|
|
3
|
+
* `SendMessageOptions.config` the loop emits. When the flag is on, the latest
|
|
4
|
+
* user message carries a volatile `<memory>` block, so the loop sets
|
|
5
|
+
* `providerConfig.mutableLatestUserMessage` to tell the provider to anchor its
|
|
6
|
+
* long-TTL cache breakpoint on the most recent STABLE message instead.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* from
|
|
10
|
-
* is
|
|
8
|
+
* The loop reads the flag directly where it assembles `providerConfig`, so the
|
|
9
|
+
* signal is sourced from the flag rather than a run option. When the flag is
|
|
10
|
+
* off the field is omitted (not `false`/`undefined`) so the wire stays
|
|
11
|
+
* byte-identical to today.
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
|
-
import { describe, expect, mock, test } from "bun:test";
|
|
14
|
+
import { afterEach, describe, expect, mock, test } from "bun:test";
|
|
14
15
|
|
|
15
16
|
import { makeMockLogger } from "./helpers/mock-logger.js";
|
|
16
17
|
|
|
@@ -19,6 +20,10 @@ mock.module("../util/logger.js", () => ({
|
|
|
19
20
|
}));
|
|
20
21
|
|
|
21
22
|
import { AgentLoop } from "../agent/loop.js";
|
|
23
|
+
import {
|
|
24
|
+
clearCachedOverrides,
|
|
25
|
+
setCachedOverrides,
|
|
26
|
+
} from "../config/feature-flag-cache.js";
|
|
22
27
|
import type {
|
|
23
28
|
Message,
|
|
24
29
|
Provider,
|
|
@@ -75,13 +80,20 @@ function makeRecordingProvider(responses: ProviderResponse[]): {
|
|
|
75
80
|
return { provider, configs: () => configs };
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
describe("AgentLoop.run — mutableLatestUserMessage
|
|
79
|
-
|
|
83
|
+
describe("AgentLoop.run — mutableLatestUserMessage from memory-v3-live", () => {
|
|
84
|
+
afterEach(() => {
|
|
85
|
+
clearCachedOverrides();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("sets mutableLatestUserMessage on every LLM call when memory-v3-live is on (multi-turn)", async () => {
|
|
89
|
+
// GIVEN memory-v3-live is enabled
|
|
90
|
+
setCachedOverrides({ "memory-v3-live": true }, { fromGateway: true });
|
|
91
|
+
|
|
92
|
+
// AND a provider that records the config of each LLM call across a tool round-trip
|
|
80
93
|
const { provider, configs } = makeRecordingProvider([
|
|
81
94
|
toolUseResponse("t1", "echo", { value: "first" }),
|
|
82
95
|
textResponse("done"),
|
|
83
96
|
]);
|
|
84
|
-
|
|
85
97
|
const dummyTools: ToolDefinition[] = [
|
|
86
98
|
{
|
|
87
99
|
name: "echo",
|
|
@@ -92,50 +104,37 @@ describe("AgentLoop.run — mutableLatestUserMessage plumbing", () => {
|
|
|
92
104
|
},
|
|
93
105
|
},
|
|
94
106
|
];
|
|
95
|
-
|
|
96
|
-
const toolExecutor = async () => ({ content: "ok", isError: false });
|
|
97
|
-
|
|
98
107
|
const loop = new AgentLoop(provider, "system", {
|
|
99
108
|
config: { maxTokens: 1024 },
|
|
100
109
|
tools: dummyTools,
|
|
101
|
-
toolExecutor:
|
|
110
|
+
toolExecutor: async () => ({ content: "ok", isError: false }),
|
|
102
111
|
});
|
|
103
112
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
mutableLatestUserMessage: true,
|
|
107
|
-
});
|
|
113
|
+
// WHEN the loop runs
|
|
114
|
+
await loop.run([userMessage], () => {}, { callSite: "mainAgent" });
|
|
108
115
|
|
|
109
|
-
//
|
|
116
|
+
// THEN every send (initial + tool round-trip) carries the cache-anchor signal
|
|
110
117
|
expect(configs()).toHaveLength(2);
|
|
111
118
|
for (const cfg of configs()) {
|
|
112
119
|
expect(cfg?.mutableLatestUserMessage).toBe(true);
|
|
113
120
|
}
|
|
114
121
|
});
|
|
115
122
|
|
|
116
|
-
test("omits mutableLatestUserMessage when
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
config: { maxTokens: 1024 },
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
await loop.run([userMessage], () => {});
|
|
123
|
+
test("omits mutableLatestUserMessage when memory-v3-live is off (flag-off byte-identity)", async () => {
|
|
124
|
+
// GIVEN memory-v3-live is off (no override; registry default is false)
|
|
125
|
+
clearCachedOverrides();
|
|
123
126
|
|
|
124
|
-
|
|
125
|
-
expect("mutableLatestUserMessage" in (configs()[0] ?? {})).toBe(false);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test("omits mutableLatestUserMessage when explicitly false (flag-off byte-identity)", async () => {
|
|
127
|
+
// AND a provider that records the config of each LLM call
|
|
129
128
|
const { provider, configs } = makeRecordingProvider([textResponse("hi")]);
|
|
130
129
|
const loop = new AgentLoop(provider, "system", {
|
|
131
130
|
config: { maxTokens: 1024 },
|
|
132
131
|
});
|
|
133
132
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
mutableLatestUserMessage: false,
|
|
137
|
-
});
|
|
133
|
+
// WHEN the loop runs
|
|
134
|
+
await loop.run([userMessage], () => {}, { callSite: "mainAgent" });
|
|
138
135
|
|
|
136
|
+
// THEN the field is omitted entirely, not carried as false/undefined
|
|
137
|
+
expect(configs()).toHaveLength(1);
|
|
139
138
|
expect("mutableLatestUserMessage" in (configs()[0] ?? {})).toBe(false);
|
|
140
139
|
});
|
|
141
140
|
});
|
|
@@ -75,6 +75,7 @@ import {
|
|
|
75
75
|
import { parentAlias } from "../messaging/providers/slack/render-transcript.js";
|
|
76
76
|
import type { Message } from "../providers/types.js";
|
|
77
77
|
import { wrapUntrustedContent } from "../security/untrusted-content.js";
|
|
78
|
+
import { getSubagentManager } from "../subagent/index.js";
|
|
78
79
|
import type { SubagentState } from "../subagent/types.js";
|
|
79
80
|
import { getWorkspacePromptPath } from "../util/platform.js";
|
|
80
81
|
|
|
@@ -123,7 +124,6 @@ function seedActiveSurfaceConversation(
|
|
|
123
124
|
data: SurfaceData,
|
|
124
125
|
channelCapabilities?: ChannelCapabilities,
|
|
125
126
|
commandIntent?: { type: string; payload?: string; languageCode?: string },
|
|
126
|
-
currentTurnIsNonInteractive?: boolean,
|
|
127
127
|
): void {
|
|
128
128
|
setConversation(conversationId, {
|
|
129
129
|
conversationId,
|
|
@@ -137,7 +137,6 @@ function seedActiveSurfaceConversation(
|
|
|
137
137
|
>([[surfaceId, { surfaceType: "dynamic_page", data }]]),
|
|
138
138
|
channelCapabilities: channelCapabilities ?? undefined,
|
|
139
139
|
commandIntent,
|
|
140
|
-
currentTurnIsNonInteractive,
|
|
141
140
|
} as never);
|
|
142
141
|
}
|
|
143
142
|
|
|
@@ -825,6 +824,8 @@ describe("applyRuntimeInjections — injection mode", () => {
|
|
|
825
824
|
};
|
|
826
825
|
|
|
827
826
|
const fullOptions = {
|
|
827
|
+
// Non-interactive turn so the `<non_interactive_context>` branch fires.
|
|
828
|
+
isNonInteractive: true,
|
|
828
829
|
unifiedTurnContext:
|
|
829
830
|
"<turn_context>\ncurrent_time: 2026-03-04 (Tuesday) 12:00:00 +00:00 (UTC)\ninterface: telegram\n</turn_context>",
|
|
830
831
|
// Guardian trust so the personal-memory gate admits the actor regardless
|
|
@@ -854,8 +855,6 @@ describe("applyRuntimeInjections — injection mode", () => {
|
|
|
854
855
|
{ html: "<div>test</div>" },
|
|
855
856
|
channelCapabilities,
|
|
856
857
|
{ type: "start" },
|
|
857
|
-
// Non-interactive turn so the `<non_interactive_context>` branch fires.
|
|
858
|
-
true,
|
|
859
858
|
);
|
|
860
859
|
});
|
|
861
860
|
afterEach(() => {
|
|
@@ -1914,6 +1913,35 @@ function makeSubagentState(
|
|
|
1914
1913
|
};
|
|
1915
1914
|
}
|
|
1916
1915
|
|
|
1916
|
+
// `applyRuntimeInjections` self-resolves the `<active_subagents>` block from the
|
|
1917
|
+
// global subagent manager keyed by the conversation, so tests seed children
|
|
1918
|
+
// directly into the manager's private maps (mirroring the production source)
|
|
1919
|
+
// rather than threading a pre-built block through options.
|
|
1920
|
+
interface SubagentManagerTestInternals {
|
|
1921
|
+
subagents: Map<string, { state: SubagentState }>;
|
|
1922
|
+
parentToChildren: Map<string, Set<string>>;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
function seedSubagentChild(
|
|
1926
|
+
parentConversationId: string,
|
|
1927
|
+
state: SubagentState,
|
|
1928
|
+
): void {
|
|
1929
|
+
const internals =
|
|
1930
|
+
getSubagentManager() as unknown as SubagentManagerTestInternals;
|
|
1931
|
+
internals.subagents.set(state.config.id, { state });
|
|
1932
|
+
const ids =
|
|
1933
|
+
internals.parentToChildren.get(parentConversationId) ?? new Set<string>();
|
|
1934
|
+
ids.add(state.config.id);
|
|
1935
|
+
internals.parentToChildren.set(parentConversationId, ids);
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
function clearSeededSubagents(): void {
|
|
1939
|
+
const internals =
|
|
1940
|
+
getSubagentManager() as unknown as SubagentManagerTestInternals;
|
|
1941
|
+
internals.subagents.clear();
|
|
1942
|
+
internals.parentToChildren.clear();
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1917
1945
|
describe("buildSubagentStatusBlock", () => {
|
|
1918
1946
|
test("returns null for empty children array", () => {
|
|
1919
1947
|
expect(buildSubagentStatusBlock([])).toBeNull();
|
|
@@ -1991,25 +2019,75 @@ describe("applyRuntimeInjections — subagent status", () => {
|
|
|
1991
2019
|
content: [{ type: "text", text: "user message" }],
|
|
1992
2020
|
};
|
|
1993
2021
|
|
|
1994
|
-
|
|
2022
|
+
afterEach(() => {
|
|
2023
|
+
clearSeededSubagents();
|
|
2024
|
+
clearConversations();
|
|
2025
|
+
});
|
|
2026
|
+
|
|
2027
|
+
test("includes self-resolved subagent status in full mode", async () => {
|
|
2028
|
+
// GIVEN the (fallback) parent conversation has one running child subagent
|
|
2029
|
+
seedSubagentChild(
|
|
2030
|
+
"runtime-assembly-fallback",
|
|
2031
|
+
makeSubagentState({ id: "child-1", label: "worker", status: "running" }),
|
|
2032
|
+
);
|
|
2033
|
+
|
|
2034
|
+
// WHEN runtime injections run in full mode
|
|
1995
2035
|
const { messages: result } = await applyRuntimeInjections([userMsg], {
|
|
1996
|
-
subagentStatusBlock:
|
|
1997
|
-
"<active_subagents>\n- [running] test\n</active_subagents>",
|
|
1998
2036
|
mode: "full",
|
|
1999
2037
|
});
|
|
2038
|
+
|
|
2039
|
+
// THEN the tail user message carries the `<active_subagents>` block the
|
|
2040
|
+
// injector self-resolved from the subagent manager
|
|
2000
2041
|
const tail = result[result.length - 1];
|
|
2001
2042
|
const texts = tail.content
|
|
2002
2043
|
.filter((b): b is { type: "text"; text: string } => b.type === "text")
|
|
2003
2044
|
.map((b) => b.text);
|
|
2004
2045
|
expect(texts.some((t) => t.includes("<active_subagents>"))).toBe(true);
|
|
2046
|
+
expect(texts.some((t) => t.includes('"worker"'))).toBe(true);
|
|
2005
2047
|
});
|
|
2006
2048
|
|
|
2007
2049
|
test("skips subagent status in minimal mode", async () => {
|
|
2050
|
+
// GIVEN the (fallback) parent conversation has one running child subagent
|
|
2051
|
+
seedSubagentChild(
|
|
2052
|
+
"runtime-assembly-fallback",
|
|
2053
|
+
makeSubagentState({ id: "child-1", label: "worker", status: "running" }),
|
|
2054
|
+
);
|
|
2055
|
+
|
|
2056
|
+
// WHEN runtime injections run in minimal mode
|
|
2008
2057
|
const { messages: result } = await applyRuntimeInjections([userMsg], {
|
|
2009
|
-
subagentStatusBlock:
|
|
2010
|
-
"<active_subagents>\n- [running] test\n</active_subagents>",
|
|
2011
2058
|
mode: "minimal",
|
|
2012
2059
|
});
|
|
2060
|
+
|
|
2061
|
+
// THEN the subagent status block is gated out
|
|
2062
|
+
const tail = result[result.length - 1];
|
|
2063
|
+
const texts = tail.content
|
|
2064
|
+
.filter((b): b is { type: "text"; text: string } => b.type === "text")
|
|
2065
|
+
.map((b) => b.text);
|
|
2066
|
+
expect(texts.some((t) => t.includes("<active_subagents>"))).toBe(false);
|
|
2067
|
+
});
|
|
2068
|
+
|
|
2069
|
+
test("skips subagent status when the conversation is itself a subagent", async () => {
|
|
2070
|
+
// GIVEN the live conversation is itself a subagent (no nesting)
|
|
2071
|
+
setConversation("runtime-assembly-fallback", {
|
|
2072
|
+
conversationId: "runtime-assembly-fallback",
|
|
2073
|
+
workingDir: "/sandbox",
|
|
2074
|
+
workspaceTopLevelContext: "",
|
|
2075
|
+
workspaceTopLevelDirty: false,
|
|
2076
|
+
surfaceState: new Map(),
|
|
2077
|
+
isSubagent: true,
|
|
2078
|
+
} as never);
|
|
2079
|
+
// AND a child is registered under its id
|
|
2080
|
+
seedSubagentChild(
|
|
2081
|
+
"runtime-assembly-fallback",
|
|
2082
|
+
makeSubagentState({ id: "child-1", label: "worker", status: "running" }),
|
|
2083
|
+
);
|
|
2084
|
+
|
|
2085
|
+
// WHEN runtime injections run in full mode
|
|
2086
|
+
const { messages: result } = await applyRuntimeInjections([userMsg], {
|
|
2087
|
+
mode: "full",
|
|
2088
|
+
});
|
|
2089
|
+
|
|
2090
|
+
// THEN no `<active_subagents>` block is emitted
|
|
2013
2091
|
const tail = result[result.length - 1];
|
|
2014
2092
|
const texts = tail.content
|
|
2015
2093
|
.filter((b): b is { type: "text"; text: string } => b.type === "text")
|
|
@@ -38,8 +38,11 @@ mock.module("../config/loader.js", () => ({
|
|
|
38
38
|
},
|
|
39
39
|
}));
|
|
40
40
|
|
|
41
|
-
const {
|
|
42
|
-
|
|
41
|
+
const {
|
|
42
|
+
applyRuntimeInjections,
|
|
43
|
+
buildSubagentStatusBlock,
|
|
44
|
+
composeInjectorChain,
|
|
45
|
+
} = await import("../daemon/conversation-runtime-assembly.js");
|
|
43
46
|
const { DEFAULT_INJECTOR_ORDER, defaultInjectors } =
|
|
44
47
|
await import("../plugins/defaults/memory-retrieval/injectors.js");
|
|
45
48
|
const { getInjectorChain } =
|
|
@@ -52,6 +55,8 @@ import { buildPkbReminder } from "../daemon/pkb-reminder-builder.js";
|
|
|
52
55
|
import { getPkbRoot } from "../memory/pkb/types.js";
|
|
53
56
|
import type { TurnContext } from "../plugins/types.js";
|
|
54
57
|
import type { Message } from "../providers/types.js";
|
|
58
|
+
import { getSubagentManager } from "../subagent/index.js";
|
|
59
|
+
import type { SubagentState } from "../subagent/types.js";
|
|
55
60
|
import { getWorkspacePromptPath } from "../util/platform.js";
|
|
56
61
|
|
|
57
62
|
// `makeTurnContext` and the workspace registry seed share this id so the
|
|
@@ -116,11 +121,63 @@ function seedWorkspaceContext(text: string): void {
|
|
|
116
121
|
} as never);
|
|
117
122
|
}
|
|
118
123
|
|
|
124
|
+
// `applyRuntimeInjections` self-resolves the `<active_subagents>` block from the
|
|
125
|
+
// global subagent manager keyed by the conversation, so tests seed children
|
|
126
|
+
// directly into the manager's private maps rather than threading a pre-built
|
|
127
|
+
// block through options.
|
|
128
|
+
interface SubagentManagerTestInternals {
|
|
129
|
+
subagents: Map<string, { state: SubagentState }>;
|
|
130
|
+
parentToChildren: Map<string, Set<string>>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function makeSubagentState(
|
|
134
|
+
id: string,
|
|
135
|
+
label: string,
|
|
136
|
+
status: SubagentState["status"],
|
|
137
|
+
): SubagentState {
|
|
138
|
+
return {
|
|
139
|
+
config: {
|
|
140
|
+
id,
|
|
141
|
+
parentConversationId: TEST_CONVERSATION_ID,
|
|
142
|
+
label,
|
|
143
|
+
objective: "obj",
|
|
144
|
+
},
|
|
145
|
+
status,
|
|
146
|
+
conversationId: `conv-${id}`,
|
|
147
|
+
isFork: false,
|
|
148
|
+
createdAt: Date.now() - 60_000,
|
|
149
|
+
startedAt: Date.now() - 55_000,
|
|
150
|
+
completedAt: status === "completed" ? Date.now() : undefined,
|
|
151
|
+
usage: { inputTokens: 0, outputTokens: 0, estimatedCost: 0 },
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function seedSubagentChild(
|
|
156
|
+
parentConversationId: string,
|
|
157
|
+
state: SubagentState,
|
|
158
|
+
): void {
|
|
159
|
+
const internals =
|
|
160
|
+
getSubagentManager() as unknown as SubagentManagerTestInternals;
|
|
161
|
+
internals.subagents.set(state.config.id, { state });
|
|
162
|
+
const ids =
|
|
163
|
+
internals.parentToChildren.get(parentConversationId) ?? new Set<string>();
|
|
164
|
+
ids.add(state.config.id);
|
|
165
|
+
internals.parentToChildren.set(parentConversationId, ids);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function clearSeededSubagents(): void {
|
|
169
|
+
const internals =
|
|
170
|
+
getSubagentManager() as unknown as SubagentManagerTestInternals;
|
|
171
|
+
internals.subagents.clear();
|
|
172
|
+
internals.parentToChildren.clear();
|
|
173
|
+
}
|
|
174
|
+
|
|
119
175
|
describe("injector chain", () => {
|
|
120
176
|
beforeEach(() => {
|
|
121
177
|
clearPkbContent();
|
|
122
178
|
clearNowScratchpad();
|
|
123
179
|
clearConversations();
|
|
180
|
+
clearSeededSubagents();
|
|
124
181
|
});
|
|
125
182
|
|
|
126
183
|
test("defaultInjectors lists the defaults in the documented order", () => {
|
|
@@ -273,14 +330,16 @@ describe("injector chain", () => {
|
|
|
273
330
|
"<workspace>\nRoot: /sandbox\nDirectories: src, lib\n</workspace>";
|
|
274
331
|
const unifiedTurn =
|
|
275
332
|
"<turn_context>\ncurrent_time: 2026-04-22\ninterface: macos\n</turn_context>";
|
|
276
|
-
|
|
277
|
-
|
|
333
|
+
// A completed child renders deterministically (no elapsed clock), so the
|
|
334
|
+
// block the injector self-resolves matches `buildSubagentStatusBlock`.
|
|
335
|
+
const subagentChild = makeSubagentState("sub-1", "worker", "completed");
|
|
336
|
+
seedSubagentChild(TEST_CONVERSATION_ID, subagentChild);
|
|
337
|
+
const subagentBlock = buildSubagentStatusBlock([subagentChild])!;
|
|
278
338
|
|
|
279
339
|
seedWorkspaceContext(workspaceText);
|
|
280
340
|
const result = await applyRuntimeInjections(runMessages, {
|
|
281
341
|
turnContext: makeTurnContext(),
|
|
282
342
|
unifiedTurnContext: unifiedTurn,
|
|
283
|
-
subagentStatusBlock: subagentBlock,
|
|
284
343
|
});
|
|
285
344
|
|
|
286
345
|
// Extract the tail user message content as a list of text strings.
|
|
@@ -391,7 +450,12 @@ describe("injector chain", () => {
|
|
|
391
450
|
// injector except `unified-turn-context` checks `mode === "full"` and
|
|
392
451
|
// opts out in minimal mode, so the tail should carry only the turn
|
|
393
452
|
// context prepend plus any non-injector hardcoded content (none
|
|
394
|
-
// here).
|
|
453
|
+
// here). A live child subagent is seeded so the subagent-status injector
|
|
454
|
+
// has a block to skip.
|
|
455
|
+
seedSubagentChild(
|
|
456
|
+
TEST_CONVERSATION_ID,
|
|
457
|
+
makeSubagentState("sub-1", "worker", "running"),
|
|
458
|
+
);
|
|
395
459
|
const result = await applyRuntimeInjections(
|
|
396
460
|
[
|
|
397
461
|
{
|
|
@@ -403,7 +467,6 @@ describe("injector chain", () => {
|
|
|
403
467
|
turnContext: makeTurnContext(),
|
|
404
468
|
mode: "minimal",
|
|
405
469
|
unifiedTurnContext: "<turn_context>...</turn_context>",
|
|
406
|
-
subagentStatusBlock: "<active_subagents>...</active_subagents>",
|
|
407
470
|
},
|
|
408
471
|
);
|
|
409
472
|
|
package/src/agent/loop.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as Sentry from "@sentry/node";
|
|
2
2
|
|
|
3
|
+
import { isAssistantFeatureFlagEnabled } from "../config/assistant-feature-flags.js";
|
|
4
|
+
import { getConfig } from "../config/loader.js";
|
|
3
5
|
import type { LLMCallSite } from "../config/schemas/llm.js";
|
|
4
6
|
import { stripInjectionsForCompaction } from "../context/strip-injections.js";
|
|
5
7
|
import {
|
|
@@ -537,14 +539,13 @@ export interface AgentLoopRunOptions {
|
|
|
537
539
|
*/
|
|
538
540
|
compaction?: MidLoopCompaction;
|
|
539
541
|
/**
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
* prefix reusable. Default unset → existing behavior.
|
|
542
|
+
* Whether the in-flight turn has no human present to answer clarification
|
|
543
|
+
* questions. Resolved once by the orchestrator at turn start and forwarded to
|
|
544
|
+
* the {@link MidLoopCompaction.postCompactionHook} so post-compaction
|
|
545
|
+
* re-injection uses the turn-start snapshot rather than re-reading mutable
|
|
546
|
+
* client/headless state mid-turn. Defaults to `false` when omitted.
|
|
546
547
|
*/
|
|
547
|
-
|
|
548
|
+
isNonInteractive?: boolean;
|
|
548
549
|
}
|
|
549
550
|
|
|
550
551
|
/**
|
|
@@ -720,6 +721,7 @@ export class AgentLoop {
|
|
|
720
721
|
signal: AbortSignal | undefined,
|
|
721
722
|
onEvent: (event: AgentEvent) => void | Promise<void>,
|
|
722
723
|
overrideProfile: string | null,
|
|
724
|
+
isNonInteractive: boolean,
|
|
723
725
|
): Promise<Message[] | null> {
|
|
724
726
|
await onEvent({ type: "context_compacting" });
|
|
725
727
|
// Strip runtime injections so the compactor summarizes the raw persistent
|
|
@@ -778,6 +780,7 @@ export class AgentLoop {
|
|
|
778
780
|
return compaction.postCompactionHook({
|
|
779
781
|
history: compactResult.compacted ? compactResult.messages : rawHistory,
|
|
780
782
|
turnContext,
|
|
783
|
+
isNonInteractive,
|
|
781
784
|
});
|
|
782
785
|
}
|
|
783
786
|
|
|
@@ -796,7 +799,7 @@ export class AgentLoop {
|
|
|
796
799
|
resolveOverrideProfile,
|
|
797
800
|
resolveContextWindow,
|
|
798
801
|
compaction,
|
|
799
|
-
|
|
802
|
+
isNonInteractive = false,
|
|
800
803
|
} = options ?? {};
|
|
801
804
|
let history = [...messages];
|
|
802
805
|
// Index into `history` where this run's appended output begins. It starts
|
|
@@ -913,12 +916,14 @@ export class AgentLoop {
|
|
|
913
916
|
providerConfig.cacheTtl = this.config.cacheTtl;
|
|
914
917
|
}
|
|
915
918
|
|
|
916
|
-
// Cache-anchor signal for volatile latest-user-message turns
|
|
917
|
-
// memory-v3 injects
|
|
918
|
-
//
|
|
919
|
-
//
|
|
920
|
-
//
|
|
921
|
-
|
|
919
|
+
// Cache-anchor signal for volatile latest-user-message turns: when
|
|
920
|
+
// memory-v3 is live it injects a per-turn `<memory>` block into the
|
|
921
|
+
// latest user message, so the provider must anchor its long-TTL cache
|
|
922
|
+
// breakpoint on the most recent STABLE user message instead of the
|
|
923
|
+
// volatile latest one. Read here alongside the rest of the provider
|
|
924
|
+
// config; only set when true so the wire/config stays byte-identical
|
|
925
|
+
// when off.
|
|
926
|
+
if (isAssistantFeatureFlagEnabled("memory-v3-live", getConfig())) {
|
|
922
927
|
providerConfig.mutableLatestUserMessage = true;
|
|
923
928
|
}
|
|
924
929
|
|
|
@@ -1638,6 +1643,7 @@ export class AgentLoop {
|
|
|
1638
1643
|
signal,
|
|
1639
1644
|
onEvent,
|
|
1640
1645
|
resolveEffectiveOverrideProfile() ?? null,
|
|
1646
|
+
isNonInteractive,
|
|
1641
1647
|
);
|
|
1642
1648
|
if (compacted) {
|
|
1643
1649
|
history = compacted;
|