@vellumai/assistant 0.8.8-dev.202606080320.8b7fbff → 0.8.8-dev.202606081143.f600053

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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/src/__tests__/agent-loop-callsite-precedence.test.ts +42 -14
  3. package/src/__tests__/agent-loop-exit-reason.test.ts +117 -91
  4. package/src/__tests__/agent-loop-mutable-latest-user-message.test.ts +12 -4
  5. package/src/__tests__/agent-loop-output-hooks.test.ts +48 -16
  6. package/src/__tests__/agent-loop-override-profile.test.ts +18 -6
  7. package/src/__tests__/agent-loop-provider-error-recording.test.ts +33 -27
  8. package/src/__tests__/agent-loop-thinking.test.ts +32 -24
  9. package/src/__tests__/agent-loop.test.ts +288 -96
  10. package/src/__tests__/agent-wake-disk-pressure-callsite.test.ts +2 -2
  11. package/src/__tests__/agent-wake-override-profile.test.ts +4 -8
  12. package/src/__tests__/approval-cascade.test.ts +4 -4
  13. package/src/__tests__/compaction-events.test.ts +4 -4
  14. package/src/__tests__/conversation-abort-tool-results.test.ts +5 -4
  15. package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +7 -9
  16. package/src/__tests__/conversation-agent-loop-overflow.test.ts +41 -14
  17. package/src/__tests__/conversation-agent-loop.test.ts +33 -195
  18. package/src/__tests__/conversation-confirmation-signals.test.ts +4 -4
  19. package/src/__tests__/conversation-process-callsite.test.ts +13 -14
  20. package/src/__tests__/conversation-provider-retry-repair.test.ts +13 -11
  21. package/src/__tests__/conversation-queue.test.ts +8 -9
  22. package/src/__tests__/conversation-slash-queue.test.ts +5 -4
  23. package/src/__tests__/conversation-slash-unknown.test.ts +5 -4
  24. package/src/__tests__/conversation-speed-override.test.ts +9 -9
  25. package/src/__tests__/conversation-workspace-cache-state.test.ts +5 -4
  26. package/src/__tests__/conversation-workspace-injection.test.ts +5 -4
  27. package/src/__tests__/conversation-workspace-tool-tracking.test.ts +5 -4
  28. package/src/__tests__/memory-retrieval-hook.test.ts +73 -6
  29. package/src/__tests__/parallel-tool.benchmark.test.ts +24 -8
  30. package/src/agent/loop.ts +62 -26
  31. package/src/daemon/conversation-agent-loop.ts +31 -126
  32. package/src/daemon/conversation.ts +3 -1
  33. package/src/plugins/defaults/memory-retrieval/hooks/user-prompt-submit-temp.ts +167 -56
  34. package/src/runtime/__tests__/agent-wake.test.ts +7 -14
  35. package/src/runtime/agent-wake.ts +22 -24
@@ -94,11 +94,15 @@ describe("agent loop output hooks", () => {
94
94
  },
95
95
  });
96
96
  const { provider } = createMockProvider([textResponse("my secret value")]);
97
- const loop = new AgentLoop(provider, "system", {
97
+ const loop = new AgentLoop({
98
+ provider: provider,
99
+ systemPrompt: "system",
98
100
  conversationId: "test-conversation",
99
101
  });
100
102
  const events: AgentEvent[] = [];
101
- const { history } = await loop.run([userMessage], collect(events), {
103
+ const { history } = await loop.run({
104
+ messages: [userMessage],
105
+ onEvent: collect(events),
102
106
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
103
107
  });
104
108
  expect(textOf(lastAssistant(history).content)).toBe("my [redacted] value");
@@ -114,11 +118,15 @@ describe("agent loop output hooks", () => {
114
118
  },
115
119
  });
116
120
  const { provider } = createMockProvider([textResponse("my secret value")]);
117
- const loop = new AgentLoop(provider, "system", {
121
+ const loop = new AgentLoop({
122
+ provider: provider,
123
+ systemPrompt: "system",
118
124
  conversationId: "test-conversation",
119
125
  });
120
126
  const events: AgentEvent[] = [];
121
- const { history } = await loop.run([userMessage], collect(events), {
127
+ const { history } = await loop.run({
128
+ messages: [userMessage],
129
+ onEvent: collect(events),
122
130
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
123
131
  });
124
132
  // Her real words never streamed; only the transformed text did, once.
@@ -134,11 +142,15 @@ describe("agent loop output hooks", () => {
134
142
  },
135
143
  });
136
144
  const { provider } = createMockProvider([textResponse("live text")]);
137
- const loop = new AgentLoop(provider, "system", {
145
+ const loop = new AgentLoop({
146
+ provider: provider,
147
+ systemPrompt: "system",
138
148
  conversationId: "test-conversation",
139
149
  });
140
150
  const events: AgentEvent[] = [];
141
- const { history } = await loop.run([userMessage], collect(events), {
151
+ const { history } = await loop.run({
152
+ messages: [userMessage],
153
+ onEvent: collect(events),
142
154
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
143
155
  });
144
156
  expect(streamedText(events)).toBe("live text"); // streamed live, untransformed
@@ -166,7 +178,9 @@ describe("agent loop output hooks", () => {
166
178
  toolAndText,
167
179
  textResponse("done"),
168
180
  ]);
169
- const loop = new AgentLoop(provider, "system", {
181
+ const loop = new AgentLoop({
182
+ provider: provider,
183
+ systemPrompt: "system",
170
184
  conversationId: "test-conversation",
171
185
  tools: [
172
186
  {
@@ -177,7 +191,9 @@ describe("agent loop output hooks", () => {
177
191
  ],
178
192
  toolExecutor: async () => ({ content: "ok", isError: false }),
179
193
  });
180
- const { history } = await loop.run([userMessage], collect([]), {
194
+ const { history } = await loop.run({
195
+ messages: [userMessage],
196
+ onEvent: collect([]),
181
197
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
182
198
  });
183
199
  const toolTurn = history.find(
@@ -202,10 +218,14 @@ describe("agent loop output hooks", () => {
202
218
  },
203
219
  });
204
220
  const { provider, calls } = createMockProvider([textResponse("hi")]);
205
- const loop = new AgentLoop(provider, "base prompt", {
221
+ const loop = new AgentLoop({
222
+ provider: provider,
223
+ systemPrompt: "base prompt",
206
224
  conversationId: "test-conversation",
207
225
  });
208
- await loop.run([userMessage], collect([]), {
226
+ await loop.run({
227
+ messages: [userMessage],
228
+ onEvent: collect([]),
209
229
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
210
230
  });
211
231
  expect(calls[0].systemPrompt).toContain("[EDITED]");
@@ -223,10 +243,14 @@ describe("agent loop output hooks", () => {
223
243
  },
224
244
  });
225
245
  const { provider } = createMockProvider([textResponse("untouched")]);
226
- const loop = new AgentLoop(provider, "system", {
246
+ const loop = new AgentLoop({
247
+ provider: provider,
248
+ systemPrompt: "system",
227
249
  conversationId: "test-conversation",
228
250
  });
229
- const { history } = await loop.run([userMessage], collect([]), {
251
+ const { history } = await loop.run({
252
+ messages: [userMessage],
253
+ onEvent: collect([]),
230
254
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
231
255
  });
232
256
  const finalContent = lastAssistant(history).content;
@@ -259,11 +283,15 @@ describe("agent loop output hooks", () => {
259
283
  stopReason: "max_tokens",
260
284
  };
261
285
  const { provider } = createMockProvider([truncated]);
262
- const loop = new AgentLoop(provider, "system", {
286
+ const loop = new AgentLoop({
287
+ provider: provider,
288
+ systemPrompt: "system",
263
289
  conversationId: "test-conversation",
264
290
  });
265
291
  const events: AgentEvent[] = [];
266
- const { history } = await loop.run([userMessage], collect(events), {
292
+ const { history } = await loop.run({
293
+ messages: [userMessage],
294
+ onEvent: collect(events),
267
295
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
268
296
  });
269
297
  expect(seen.calls).toBe(1);
@@ -294,7 +322,9 @@ describe("agent loop output hooks", () => {
294
322
  textResponse(`Your code is ${placeholder}.`),
295
323
  ];
296
324
  const { provider } = createMockProvider(toolThenText);
297
- const loop = new AgentLoop(provider, "system", {
325
+ const loop = new AgentLoop({
326
+ provider: provider,
327
+ systemPrompt: "system",
298
328
  conversationId: "test-conversation",
299
329
  tools: [
300
330
  {
@@ -310,7 +340,9 @@ describe("agent loop output hooks", () => {
310
340
  }),
311
341
  });
312
342
  const events: AgentEvent[] = [];
313
- const { history } = await loop.run([userMessage], collect(events), {
343
+ const { history } = await loop.run({
344
+ messages: [userMessage],
345
+ onEvent: collect(events),
314
346
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
315
347
  });
316
348
  // Persisted message keeps the placeholder — model must never see real
@@ -110,14 +110,18 @@ describe("AgentLoop.run — overrideProfile plumbing", () => {
110
110
  _input: Record<string, unknown>,
111
111
  ) => ({ content: "ok", isError: false });
112
112
 
113
- const loop = new AgentLoop(provider, "system", {
113
+ const loop = new AgentLoop({
114
+ provider: provider,
115
+ systemPrompt: "system",
114
116
  conversationId: "test-conversation",
115
117
  config: { maxTokens: 1024 },
116
118
  tools: dummyTools,
117
119
  toolExecutor: toolExecutor,
118
120
  });
119
121
 
120
- await loop.run([userMessage], () => {}, {
122
+ await loop.run({
123
+ messages: [userMessage],
124
+ onEvent: () => {},
121
125
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
122
126
  callSite: "mainAgent",
123
127
  overrideProfile: "fast",
@@ -132,12 +136,16 @@ describe("AgentLoop.run — overrideProfile plumbing", () => {
132
136
 
133
137
  test("omits overrideProfile from providerConfig when unset (default behavior unchanged)", async () => {
134
138
  const { provider, configs } = makeRecordingProvider([textResponse("hi")]);
135
- const loop = new AgentLoop(provider, "system", {
139
+ const loop = new AgentLoop({
140
+ provider: provider,
141
+ systemPrompt: "system",
136
142
  conversationId: "test-conversation",
137
143
  config: { maxTokens: 1024 },
138
144
  });
139
145
 
140
- await loop.run([userMessage], () => {}, {
146
+ await loop.run({
147
+ messages: [userMessage],
148
+ onEvent: () => {},
141
149
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
142
150
  });
143
151
 
@@ -153,12 +161,16 @@ describe("AgentLoop.run — overrideProfile plumbing", () => {
153
161
  // receives so a non-existent profile silently falls back at the
154
162
  // provider layer (covered by provider-send-message-override-profile.test.ts).
155
163
  const { provider, configs } = makeRecordingProvider([textResponse("hi")]);
156
- const loop = new AgentLoop(provider, "system", {
164
+ const loop = new AgentLoop({
165
+ provider: provider,
166
+ systemPrompt: "system",
157
167
  conversationId: "test-conversation",
158
168
  config: { maxTokens: 1024 },
159
169
  });
160
170
 
161
- await loop.run([userMessage], () => {}, {
171
+ await loop.run({
172
+ messages: [userMessage],
173
+ onEvent: () => {},
162
174
  trust: { sourceChannel: "vellum", trustClass: "unknown" },
163
175
  callSite: "mainAgent",
164
176
  overrideProfile: "does-not-exist",
@@ -83,17 +83,19 @@ describe("AgentLoop provider_error event emission", () => {
83
83
  const { provider, calls } = makeThrowingProvider("anthropic", () => thrown);
84
84
 
85
85
  const events: AgentEvent[] = [];
86
- const loop = new AgentLoop(provider, "you are a helpful assistant", {
86
+ const loop = new AgentLoop({
87
+ provider: provider,
88
+ systemPrompt: "you are a helpful assistant",
87
89
  conversationId: "test-conversation",
88
90
  });
89
91
 
90
- await loop.run(
91
- [{ role: "user", content: [{ type: "text", text: "hi" }] }],
92
- (e) => {
92
+ await loop.run({
93
+ messages: [{ role: "user", content: [{ type: "text", text: "hi" }] }],
94
+ onEvent: (e) => {
93
95
  events.push(e);
94
96
  },
95
- { trust: { sourceChannel: "vellum", trustClass: "unknown" } },
96
- );
97
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
98
+ });
97
99
 
98
100
  expect(calls).toHaveLength(1);
99
101
 
@@ -125,17 +127,19 @@ describe("AgentLoop provider_error event emission", () => {
125
127
  const { provider } = makeThrowingProvider("gemini", () => thrown);
126
128
 
127
129
  const events: AgentEvent[] = [];
128
- const loop = new AgentLoop(provider, "system", {
130
+ const loop = new AgentLoop({
131
+ provider: provider,
132
+ systemPrompt: "system",
129
133
  conversationId: "test-conversation",
130
134
  });
131
135
 
132
- await loop.run(
133
- [{ role: "user", content: [{ type: "text", text: "hi" }] }],
134
- (e) => {
136
+ await loop.run({
137
+ messages: [{ role: "user", content: [{ type: "text", text: "hi" }] }],
138
+ onEvent: (e) => {
135
139
  events.push(e);
136
140
  },
137
- { trust: { sourceChannel: "vellum", trustClass: "unknown" } },
138
- );
141
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
142
+ });
139
143
 
140
144
  const providerErrorIdx = events.findIndex(
141
145
  (e) => e.type === "provider_error",
@@ -154,17 +158,19 @@ describe("AgentLoop provider_error event emission", () => {
154
158
  const { provider } = makeThrowingProvider("openai", () => thrown);
155
159
 
156
160
  const events: AgentEvent[] = [];
157
- const loop = new AgentLoop(provider, "system", {
161
+ const loop = new AgentLoop({
162
+ provider: provider,
163
+ systemPrompt: "system",
158
164
  conversationId: "test-conversation",
159
165
  });
160
166
 
161
- await loop.run(
162
- [{ role: "user", content: [{ type: "text", text: "hi" }] }],
163
- (e) => {
167
+ await loop.run({
168
+ messages: [{ role: "user", content: [{ type: "text", text: "hi" }] }],
169
+ onEvent: (e) => {
164
170
  events.push(e);
165
171
  },
166
- { trust: { sourceChannel: "vellum", trustClass: "unknown" } },
167
- );
172
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
173
+ });
168
174
 
169
175
  const providerErrorEvent = events.find((e) => e.type === "provider_error");
170
176
  expect(providerErrorEvent).toBeDefined();
@@ -188,20 +194,20 @@ describe("AgentLoop provider_error event emission", () => {
188
194
  });
189
195
 
190
196
  const events: AgentEvent[] = [];
191
- const loop = new AgentLoop(provider, "system", {
197
+ const loop = new AgentLoop({
198
+ provider: provider,
199
+ systemPrompt: "system",
192
200
  conversationId: "test-conversation",
193
201
  });
194
202
 
195
- await loop.run(
196
- [{ role: "user", content: [{ type: "text", text: "hi" }] }],
197
- (e) => {
203
+ await loop.run({
204
+ messages: [{ role: "user", content: [{ type: "text", text: "hi" }] }],
205
+ onEvent: (e) => {
198
206
  events.push(e);
199
207
  },
200
- {
201
- trust: { sourceChannel: "vellum", trustClass: "unknown" },
202
- signal: controller.signal,
203
- },
204
- );
208
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
209
+ signal: controller.signal,
210
+ });
205
211
 
206
212
  const providerErrorEvent = events.find((e) => e.type === "provider_error");
207
213
  // Cancellation should never produce a recording row — there's no
@@ -37,7 +37,9 @@ function createMockProvider(): {
37
37
  describe("AgentLoop thinking and effort", () => {
38
38
  test("sends adaptive thinking when thinking is enabled", async () => {
39
39
  const { provider, lastConfig } = createMockProvider();
40
- const loop = new AgentLoop(provider, "test", {
40
+ const loop = new AgentLoop({
41
+ provider: provider,
42
+ systemPrompt: "test",
41
43
  conversationId: "test-conversation",
42
44
  config: {
43
45
  maxTokens: 64000,
@@ -45,11 +47,11 @@ describe("AgentLoop thinking and effort", () => {
45
47
  },
46
48
  });
47
49
 
48
- await loop.run(
49
- [{ role: "user", content: [{ type: "text", text: "Hi" }] }],
50
- () => {},
51
- { trust: { sourceChannel: "vellum", trustClass: "unknown" } },
52
- );
50
+ await loop.run({
51
+ messages: [{ role: "user", content: [{ type: "text", text: "Hi" }] }],
52
+ onEvent: () => {},
53
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
54
+ });
53
55
 
54
56
  const config = lastConfig()!;
55
57
  const thinking = config.thinking as { type: string };
@@ -58,7 +60,9 @@ describe("AgentLoop thinking and effort", () => {
58
60
 
59
61
  test("sends disabled thinking when thinking is disabled", async () => {
60
62
  const { provider, lastConfig } = createMockProvider();
61
- const loop = new AgentLoop(provider, "test", {
63
+ const loop = new AgentLoop({
64
+ provider: provider,
65
+ systemPrompt: "test",
62
66
  conversationId: "test-conversation",
63
67
  config: {
64
68
  maxTokens: 64000,
@@ -66,11 +70,11 @@ describe("AgentLoop thinking and effort", () => {
66
70
  },
67
71
  });
68
72
 
69
- await loop.run(
70
- [{ role: "user", content: [{ type: "text", text: "Hi" }] }],
71
- () => {},
72
- { trust: { sourceChannel: "vellum", trustClass: "unknown" } },
73
- );
73
+ await loop.run({
74
+ messages: [{ role: "user", content: [{ type: "text", text: "Hi" }] }],
75
+ onEvent: () => {},
76
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
77
+ });
74
78
 
75
79
  const config = lastConfig()!;
76
80
  expect(config.thinking).toEqual({ type: "disabled" });
@@ -78,7 +82,9 @@ describe("AgentLoop thinking and effort", () => {
78
82
 
79
83
  test("sends effort in provider config", async () => {
80
84
  const { provider, lastConfig } = createMockProvider();
81
- const loop = new AgentLoop(provider, "test", {
85
+ const loop = new AgentLoop({
86
+ provider: provider,
87
+ systemPrompt: "test",
82
88
  conversationId: "test-conversation",
83
89
  config: {
84
90
  maxTokens: 64000,
@@ -86,11 +92,11 @@ describe("AgentLoop thinking and effort", () => {
86
92
  },
87
93
  });
88
94
 
89
- await loop.run(
90
- [{ role: "user", content: [{ type: "text", text: "Hi" }] }],
91
- () => {},
92
- { trust: { sourceChannel: "vellum", trustClass: "unknown" } },
93
- );
95
+ await loop.run({
96
+ messages: [{ role: "user", content: [{ type: "text", text: "Hi" }] }],
97
+ onEvent: () => {},
98
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
99
+ });
94
100
 
95
101
  const config = lastConfig()!;
96
102
  expect(config.effort).toBe("high");
@@ -98,7 +104,9 @@ describe("AgentLoop thinking and effort", () => {
98
104
 
99
105
  test("sends effort with disabled thinking when thinking is disabled", async () => {
100
106
  const { provider, lastConfig } = createMockProvider();
101
- const loop = new AgentLoop(provider, "test", {
107
+ const loop = new AgentLoop({
108
+ provider: provider,
109
+ systemPrompt: "test",
102
110
  conversationId: "test-conversation",
103
111
  config: {
104
112
  maxTokens: 64000,
@@ -107,11 +115,11 @@ describe("AgentLoop thinking and effort", () => {
107
115
  },
108
116
  });
109
117
 
110
- await loop.run(
111
- [{ role: "user", content: [{ type: "text", text: "Hi" }] }],
112
- () => {},
113
- { trust: { sourceChannel: "vellum", trustClass: "unknown" } },
114
- );
118
+ await loop.run({
119
+ messages: [{ role: "user", content: [{ type: "text", text: "Hi" }] }],
120
+ onEvent: () => {},
121
+ trust: { sourceChannel: "vellum", trustClass: "unknown" },
122
+ });
115
123
 
116
124
  const config = lastConfig()!;
117
125
  expect(config.effort).toBe("medium");