@vellumai/assistant 0.10.9-dev.202607152124.584d617 → 0.10.9-dev.202607152225.ec6fdbf

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 (71) hide show
  1. package/ARCHITECTURE.md +1 -1
  2. package/package.json +1 -1
  3. package/src/__tests__/agent-loop-override-profile.test.ts +22 -25
  4. package/src/__tests__/agent-wake-override-profile.test.ts +21 -48
  5. package/src/__tests__/compaction.benchmark.test.ts +2 -1
  6. package/src/__tests__/config-loader-backfill.test.ts +9 -4
  7. package/src/__tests__/config-schema-cmd.test.ts +10 -11
  8. package/src/__tests__/config-schema.test.ts +164 -227
  9. package/src/__tests__/conversation-agent-loop-overflow.test.ts +5 -19
  10. package/src/__tests__/conversation-agent-loop.test.ts +13 -6
  11. package/src/__tests__/conversation-process-callsite.test.ts +12 -19
  12. package/src/__tests__/conversation-routes-slash-commands.test.ts +7 -21
  13. package/src/__tests__/conversation-usage.test.ts +4 -12
  14. package/src/__tests__/heartbeat-service.test.ts +0 -28
  15. package/src/__tests__/inference-no-mode-boot-e2e.test.ts +52 -8
  16. package/src/__tests__/invite-routes-http.test.ts +12 -16
  17. package/src/__tests__/llm-context-resolution.test.ts +32 -56
  18. package/src/__tests__/llm-resolver-override-or-default.test.ts +3 -52
  19. package/src/__tests__/llm-resolver.test.ts +342 -602
  20. package/src/__tests__/llm-schema.test.ts +79 -37
  21. package/src/__tests__/provider-commit-message-generator.test.ts +27 -20
  22. package/src/__tests__/provider-platform-proxy-integration.test.ts +10 -31
  23. package/src/__tests__/provider-registry-ollama.test.ts +8 -18
  24. package/src/__tests__/provider-send-message-override-profile.test.ts +23 -23
  25. package/src/__tests__/provider-usage-tracking.test.ts +9 -19
  26. package/src/__tests__/retry-openrouter-only-normalization.test.ts +22 -23
  27. package/src/__tests__/retry-thinking-adaptive-only.test.ts +43 -48
  28. package/src/__tests__/retry-thinking-tool-choice.test.ts +57 -66
  29. package/src/__tests__/retry-verbosity-normalization.test.ts +24 -23
  30. package/src/__tests__/run-conversation-turn-persistence.test.ts +113 -0
  31. package/src/__tests__/subagent-call-site-routing.test.ts +69 -95
  32. package/src/__tests__/tool-profiler.test.ts +72 -1
  33. package/src/__tests__/usage-attribution.test.ts +18 -41
  34. package/src/agent/loop.ts +4 -3
  35. package/src/cli/commands/config.help.ts +6 -6
  36. package/src/cli/commands/inference.help.ts +2 -2
  37. package/src/config/__tests__/default-profile-catalog.test.ts +8 -12
  38. package/src/config/__tests__/profile-materialization.test.ts +1 -88
  39. package/src/config/bundled-skills/phone-calls/references/CONFIG.md +7 -7
  40. package/src/config/call-site-defaults.ts +3 -3
  41. package/src/config/feature-flag-registry.json +1 -13
  42. package/src/config/llm-resolver.ts +88 -475
  43. package/src/config/profile-materialization.ts +11 -11
  44. package/src/config/schema.ts +93 -127
  45. package/src/config/schemas/llm.ts +51 -15
  46. package/src/daemon/conversation-agent-loop.ts +10 -17
  47. package/src/daemon/conversation-error.ts +36 -14
  48. package/src/daemon/lifecycle.ts +2 -2
  49. package/src/notifications/README.md +1 -1
  50. package/src/plugin-api/conversation-turn.ts +29 -13
  51. package/src/plugin-api/vision-support.test.ts +8 -19
  52. package/src/plugin-api/vision-support.ts +26 -17
  53. package/src/plugins/defaults/memory/v2/migration.ts +46 -16
  54. package/src/providers/__tests__/dispatch-connection-routing.test.ts +6 -9
  55. package/src/providers/__tests__/registry-native-web-search.test.ts +4 -10
  56. package/src/providers/__tests__/retry-callsite.test.ts +235 -215
  57. package/src/providers/__tests__/satellite-connection-routing.test.ts +8 -16
  58. package/src/providers/call-site-routing.ts +7 -3
  59. package/src/providers/connection-resolution.ts +9 -11
  60. package/src/providers/inference/backfill.ts +25 -9
  61. package/src/providers/types.ts +11 -4
  62. package/src/runtime/agent-wake.ts +31 -24
  63. package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +17 -30
  64. package/src/runtime/routes/conversation-query-routes.ts +4 -4
  65. package/src/runtime/routes/inference-provider-connection-routes.ts +19 -18
  66. package/src/runtime/routes/inference-send-routes.ts +1 -1
  67. package/src/subagent/manager.ts +4 -3
  68. package/src/tools/subagent/spawn.ts +7 -11
  69. package/src/tools/tool-profiler.ts +37 -6
  70. package/src/usage/attribution.ts +18 -112
  71. package/src/workspace/provider-commit-message-generator.ts +6 -4
package/ARCHITECTURE.md CHANGED
@@ -1944,7 +1944,7 @@ Connected channels are resolved at signal emission time: vellum is always includ
1944
1944
 
1945
1945
  **Audit trail (SQLite):** `notification_events` → `notification_decisions` (with `conversationActions` in validation results) → `notification_deliveries` (with `conversation_id`, `message_id`, `conversation_strategy`, `conversation_action`, `conversation_target_id`, `conversation_fallback_used`)
1946
1946
 
1947
- **Configuration:** `llm.callSites.notificationDecision` (decision engine) and `llm.callSites.preferenceExtraction` (preference extractor) in `config.json`. Both fall back to `llm.default` when unset.
1947
+ **Configuration:** `llm.callSites.notificationDecision` (decision engine) and `llm.callSites.preferenceExtraction` (preference extractor) in `config.json`. Both fall back to their shipped call-site defaults when unset.
1948
1948
 
1949
1949
  ---
1950
1950
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.9-dev.202607152124.584d617",
3
+ "version": "0.10.9-dev.202607152225.ec6fdbf",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -13,20 +13,13 @@
13
13
  * field is omitted from `providerConfig` rather than carrying `undefined`.
14
14
  */
15
15
 
16
- import { beforeAll, describe, expect, mock, test } from "bun:test";
17
-
18
- import { setOverridesForTesting } from "./feature-flag-test-helpers.js";
19
- import { setConfig } from "./helpers/set-config.js";
16
+ import { describe, expect, mock, test } from "bun:test";
20
17
 
21
18
  // These suites exercise override-profile PLUMBING through legacy-shaped
22
19
  // fixtures (llm.default-centric, no defaultProvider). Pinned to the
23
20
  // flag-off cascade; override-or-default resolution semantics are pinned by
24
21
  // llm-resolver-override-or-default.test.ts and the inference-profile loop
25
22
  // suite.
26
- beforeAll(() => {
27
- setOverridesForTesting({ "override-or-default-resolution": false });
28
- });
29
-
30
23
  import { AgentLoop } from "../agent/loop.js";
31
24
  import type {
32
25
  Message,
@@ -35,6 +28,7 @@ import type {
35
28
  SendMessageOptions,
36
29
  ToolDefinition,
37
30
  } from "../providers/types.js";
31
+ import { setConfig } from "./helpers/set-config.js";
38
32
 
39
33
  const userMessage: Message = {
40
34
  role: "user",
@@ -277,14 +271,20 @@ mock.module("../providers/registry.js", () => ({
277
271
  resolveProviderFromConnection: async () => anthropicStub,
278
272
  }));
279
273
 
274
+ import { VELLUM_MANAGED_CONNECTION_NAME } from "../providers/vellum-model-routing.js";
275
+
280
276
  // Connection-aware resolver path: satisfy
281
277
  // `tryResolveProviderForConnectionName` lookups so resolveDefaultProvider
282
- // returns a usable provider for the inline `anthropic-conn` fixture.
278
+ // returns a usable provider for any connection name the winning profile
279
+ // references. The managed connection must carry the provider the catalog
280
+ // `balanced` default declares (fireworks) or resolution rejects the row as a
281
+ // provider mismatch; other names behave as personal anthropic connections.
283
282
  mock.module("../providers/inference/connections.js", () => ({
284
283
  getConnection: (_db: unknown, name: string) => ({
285
284
  id: 1,
286
285
  name,
287
- provider: "anthropic",
286
+ provider:
287
+ name === VELLUM_MANAGED_CONNECTION_NAME ? "fireworks" : "anthropic",
288
288
  auth_strategy: "user_managed_credential",
289
289
  credential_alias: null,
290
290
  metadata_json: null,
@@ -295,21 +295,16 @@ mock.module("../providers/inference/connections.js", () => ({
295
295
 
296
296
  /**
297
297
  * Seed the workspace `llm` config block for real. `activeProfile` and
298
- * `callSites` vary per test; the rest is the shared legacy-shaped fixture.
298
+ * `callSites` vary per test.
299
299
  */
300
300
  function seedLlmConfig(options?: {
301
301
  activeProfile?: string;
302
302
  callSites?: Record<string, unknown>;
303
303
  }): void {
304
304
  setConfig("llm", {
305
- default: {
306
- provider: "anthropic",
307
- model: "claude-opus-4-7",
308
- provider_connection: "anthropic-conn",
309
- },
310
305
  profiles: {
311
- // Disable the catalog default so resolution lands on llm.default.
312
- balanced: { source: "managed", status: "disabled" },
306
+ // Complete (provider + model) so the profile is a usable winner at
307
+ // every rung of the single-winner selection chain.
313
308
  fast: {
314
309
  source: "user",
315
310
  provider: "anthropic",
@@ -457,7 +452,7 @@ describe("executeSubagentSpawn — nested inheritance via context.overrideProfil
457
452
  }
458
453
  });
459
454
 
460
- test("omits overrideProfile when neither context nor row carries it", async () => {
455
+ test("forwards the invoker's resolved default profile when neither context nor row carries an override", async () => {
461
456
  const manager = getSubagentManager();
462
457
  const originalSpawn = manager.spawn.bind(manager);
463
458
  let capturedConfig: Record<string, unknown> | undefined;
@@ -479,10 +474,11 @@ describe("executeSubagentSpawn — nested inheritance via context.overrideProfil
479
474
  );
480
475
 
481
476
  expect(capturedConfig).toBeDefined();
482
- // Field must be absent rather than carrying `undefined` so the
483
- // SubagentConfig respects the same "field omitted when unset"
484
- // contract the agent loop uses.
485
- expect("overrideProfile" in capturedConfig!).toBe(false);
477
+ // With no explicit override anywhere, the invoker-default tier forwards
478
+ // the invoking call site's resolved default profile — here `mainAgent`
479
+ // with no active profile or pin, which resolves the catalog `balanced`
480
+ // default — so the subagent matches its invoker's model selection.
481
+ expect(capturedConfig!.overrideProfile).toBe("balanced");
486
482
  } finally {
487
483
  manager.spawn = originalSpawn;
488
484
  }
@@ -491,8 +487,9 @@ describe("executeSubagentSpawn — nested inheritance via context.overrideProfil
491
487
  test("an explicit subagentSpawn call-site pin suppresses the invoker-default inheritance", async () => {
492
488
  // With an active profile the invoker-default tier resolves ("fast"), so
493
489
  // absent a pin it is forwarded as the inherited override; with an
494
- // explicit llm.callSites.subagentSpawn profile the heuristic must yield
495
- // so the pin can win under override-or-default resolution.
490
+ // explicit llm.callSites.subagentSpawn profile the heuristic must yield —
491
+ // a forwarded override would outrank the pin under single-winner
492
+ // resolution, overriding the user's explicit call-site choice.
496
493
  const manager = getSubagentManager();
497
494
  const originalSpawn = manager.spawn.bind(manager);
498
495
  let capturedConfig: Record<string, unknown> | undefined;
@@ -26,26 +26,7 @@
26
26
  * pinned-profile values.
27
27
  */
28
28
 
29
- import {
30
- afterEach,
31
- beforeAll,
32
- beforeEach,
33
- describe,
34
- expect,
35
- mock,
36
- test,
37
- } from "bun:test";
38
-
39
- import { setOverridesForTesting } from "./feature-flag-test-helpers.js";
40
-
41
- // These suites exercise override-profile PLUMBING through legacy-shaped
42
- // fixtures (llm.default-centric, no defaultProvider). Pinned to the
43
- // flag-off cascade; override-or-default resolution semantics are pinned by
44
- // llm-resolver-override-or-default.test.ts and the inference-profile loop
45
- // suite.
46
- beforeAll(() => {
47
- setOverridesForTesting({ "override-or-default-resolution": false });
48
- });
29
+ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
49
30
 
50
31
  let mockOverrideProfile: string | undefined = undefined;
51
32
 
@@ -140,14 +121,12 @@ describe("wakeAgentForOpportunity — overrideProfile forwarding", () => {
140
121
  test("forwards the conversation's pinned overrideProfile + mainAgent callSite to agentLoop.run", async () => {
141
122
  mockOverrideProfile = "frontier";
142
123
  setLlmConfig({
143
- default: {
144
- provider: "anthropic",
145
- model: "claude-sonnet-4-6",
146
- maxTokens: 64000,
147
- contextWindow: { maxInputTokens: 200000 },
148
- },
149
124
  profiles: {
125
+ // Complete (provider + model) so the pinned profile is a usable
126
+ // winner; its context window is what the wake must resolve.
150
127
  frontier: {
128
+ provider: "anthropic",
129
+ model: "claude-sonnet-4-6",
151
130
  contextWindow: { maxInputTokens: 150000 },
152
131
  },
153
132
  },
@@ -184,23 +163,24 @@ describe("wakeAgentForOpportunity — overrideProfile forwarding", () => {
184
163
  test("forceOverrideProfile replaces the pinned-profile lookup and forwards the force flag to agentLoop.run", async () => {
185
164
  // The conversation's own pinned profile must be ignored — the caller's
186
165
  // forced profile (e.g. a fork-based retrospective matching the source
187
- // conversation) takes its place AND floats above the call-site layers
188
- // via the resolver's `forceOverrideProfile` escape hatch.
166
+ // conversation) takes its place and, as the override rung of the
167
+ // single-winner chain, beats the call site's own pinned profile.
189
168
  mockOverrideProfile = "pinned-ignored";
190
169
  setLlmConfig({
191
- default: {
192
- provider: "anthropic",
193
- model: "claude-sonnet-4-6",
194
- maxTokens: 64000,
195
- contextWindow: { maxInputTokens: 200000 },
196
- },
197
170
  profiles: {
198
171
  forced: {
172
+ provider: "anthropic",
173
+ model: "claude-sonnet-4-6",
199
174
  contextWindow: { maxInputTokens: 120000 },
200
175
  },
176
+ "retrospective-pinned": {
177
+ provider: "anthropic",
178
+ model: "claude-sonnet-4-6",
179
+ contextWindow: { maxInputTokens: 180000 },
180
+ },
201
181
  },
202
182
  callSites: {
203
- memoryRetrospective: { contextWindow: { maxInputTokens: 180000 } },
183
+ memoryRetrospective: { profile: "retrospective-pinned" },
204
184
  },
205
185
  });
206
186
  const { target, runArgs } = makeTarget();
@@ -221,8 +201,9 @@ describe("wakeAgentForOpportunity — overrideProfile forwarding", () => {
221
201
  expect(runArgs[0]!.options?.overrideProfile).toBe("forced");
222
202
  expect(runArgs[0]!.options?.forceOverrideProfile).toBe(true);
223
203
  expect(runArgs[0]!.options?.callSite).toBe("memoryRetrospective");
224
- // The effective context window resolves under the FORCED profile, above
225
- // the explicit call-site override (120k beats the call site's 180k).
204
+ // The effective context window resolves under the FORCED profile, which
205
+ // wins selection over the call site's own pinned profile (the forced
206
+ // profile's 120k beats the call-site profile's 180k).
226
207
  expect(runArgs[0]!.options?.resolveContextWindow?.().maxInputTokens).toBe(
227
208
  120000,
228
209
  );
@@ -231,13 +212,9 @@ describe("wakeAgentForOpportunity — overrideProfile forwarding", () => {
231
212
  test("without forceOverrideProfile the wake never sets the force flag", async () => {
232
213
  mockOverrideProfile = "frontier";
233
214
  setLlmConfig({
234
- default: {
235
- provider: "anthropic",
236
- model: "claude-sonnet-4-6",
237
- maxTokens: 64000,
238
- contextWindow: { maxInputTokens: 200000 },
215
+ profiles: {
216
+ frontier: { provider: "anthropic", model: "claude-sonnet-4-6" },
239
217
  },
240
- profiles: { frontier: {} },
241
218
  callSites: { mainAgent: {} },
242
219
  });
243
220
  const { target, runArgs } = makeTarget();
@@ -317,13 +294,9 @@ describe("wakeAgentForOpportunity — resolver actually engages", () => {
317
294
  // undefined (the original bug), the retry layer would skip the resolver
318
295
  // entirely and the downstream provider would see only the wire defaults.
319
296
  setLlmConfig({
320
- default: {
321
- provider: "anthropic",
322
- model: "claude-sonnet-4-6",
323
- maxTokens: 64000,
324
- },
325
297
  profiles: {
326
298
  frontier: {
299
+ provider: "anthropic",
327
300
  model: "claude-opus-4-7",
328
301
  maxTokens: 32000,
329
302
  },
@@ -25,6 +25,7 @@ mock.module("../persistence/llm-request-log-store.js", () => ({
25
25
  }));
26
26
 
27
27
  import { DEFAULT_CONFIG } from "../config/defaults.js";
28
+ import { resolveCallSiteConfig } from "../config/llm-resolver.js";
28
29
  import { estimatePromptTokens } from "../context/token-estimator.js";
29
30
  import { ContextWindowManager } from "../plugins/defaults/compaction/window-manager.js";
30
31
  import type { Message, Provider } from "../providers/types.js";
@@ -98,7 +99,7 @@ function makeLongMessages(turns: number): Message[] {
98
99
 
99
100
  function makeConfig() {
100
101
  return {
101
- ...DEFAULT_CONFIG.llm.default.contextWindow,
102
+ ...resolveCallSiteConfig("mainAgent", DEFAULT_CONFIG.llm).contextWindow,
102
103
  maxInputTokens: 6000,
103
104
  targetBudgetRatio: 0.4,
104
105
  compactThreshold: 0.6,
@@ -36,7 +36,9 @@ function ensureTestDir(): void {
36
36
  join(WORKSPACE_DIR, "data", "logs"),
37
37
  ];
38
38
  for (const dir of dirs) {
39
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
39
+ if (!existsSync(dir)) {
40
+ mkdirSync(dir, { recursive: true });
41
+ }
40
42
  }
41
43
  }
42
44
 
@@ -380,7 +382,9 @@ describe("loadConfig startup behavior", () => {
380
382
  }
381
383
  // Clear any leftover config-quarantine notice sentinel from prior runs.
382
384
  const noticePath = getConfigQuarantineNoticePath();
383
- if (existsSync(noticePath)) rmSync(noticePath, { force: true });
385
+ if (existsSync(noticePath)) {
386
+ rmSync(noticePath, { force: true });
387
+ }
384
388
  ensureTestDir();
385
389
  setStorePathForTesting(join(WORKSPACE_DIR, "keys.enc"));
386
390
  delete process.env.VELLUM_DEFAULT_WORKSPACE_CONFIG_PATH;
@@ -573,8 +577,9 @@ describe("loadConfig startup behavior", () => {
573
577
  mergeDefaultConfigAndSeedInferenceProfiles();
574
578
  const config = loadConfig();
575
579
 
576
- expect(config.llm.default.provider).toBe("anthropic");
577
- expect(config.llm.default.model).toBe("claude-opus-4-7");
580
+ // `llm.default` is not part of the schema — the overlay blob stays on
581
+ // disk as inert user intent but never reaches the parsed config.
582
+ expect((config.llm as Record<string, unknown>).default).toBeUndefined();
578
583
  // Off-platform: user profiles are active, backed by the user's API key.
579
584
  expect(config.llm.activeProfile).toBe("custom-balanced");
580
585
  expect(config.llm.profiles["custom-balanced"]?.provider).toBe("anthropic");
@@ -17,7 +17,9 @@ function ensureTestDir(): void {
17
17
  join(WORKSPACE_DIR, "data", "logs"),
18
18
  ];
19
19
  for (const dir of dirs) {
20
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
20
+ if (!existsSync(dir)) {
21
+ mkdirSync(dir, { recursive: true });
22
+ }
21
23
  }
22
24
  }
23
25
 
@@ -62,10 +64,7 @@ let mockIpcResult: {
62
64
 
63
65
  mock.module("../ipc/cli-client.js", () => ({
64
66
  cliIpcCall: async () => mockIpcResult,
65
- exitFromIpcResult: (r: {
66
- error?: string;
67
- statusCode?: number;
68
- }) => {
67
+ exitFromIpcResult: (r: { error?: string; statusCode?: number }) => {
69
68
  process.stderr.write((r.error ?? "Unknown error") + "\n");
70
69
  if (r.statusCode === undefined) {
71
70
  process.exit(10);
@@ -91,15 +90,15 @@ import { getSchemaAtPath } from "../config/schema-utils.js";
91
90
  // ---------------------------------------------------------------------------
92
91
 
93
92
  describe("getSchemaAtPath", () => {
94
- test("returns full schema for a leaf key (llm.default.maxTokens → number schema)", () => {
93
+ test("returns full schema for a leaf key (llm.profileSession.defaultTtlSeconds → number schema)", () => {
95
94
  const result = getSchemaAtPath(
96
95
  AssistantConfigSchema,
97
- "llm.default.maxTokens",
96
+ "llm.profileSession.defaultTtlSeconds",
98
97
  );
99
98
  expect(result).not.toBeNull();
100
- // maxTokens has a default, so it should be parseable
99
+ // defaultTtlSeconds has a default, so it should be parseable
101
100
  const parsed = (result as z.ZodType).parse(undefined);
102
- expect(parsed).toBe(64000);
101
+ expect(parsed).toBe(1800);
103
102
  });
104
103
 
105
104
  test("navigates nested paths (memory.segmentation → object schema)", () => {
@@ -234,10 +233,10 @@ describe("z.toJSONSchema integration", () => {
234
233
  expect(properties!.safety).toBeDefined();
235
234
  });
236
235
 
237
- test("sub-schema at a leaf like llm.default.maxTokens produces integer schema", () => {
236
+ test("sub-schema at a leaf like llm.profileSession.defaultTtlSeconds produces integer schema", () => {
238
237
  const maxTokensSchema = getSchemaAtPath(
239
238
  AssistantConfigSchema,
240
- "llm.default.maxTokens",
239
+ "llm.profileSession.defaultTtlSeconds",
241
240
  );
242
241
  expect(maxTokensSchema).not.toBeNull();
243
242
  const jsonSchema = z.toJSONSchema(maxTokensSchema!, {