@vellumai/assistant 0.10.10-dev.202607211537.40f1959 → 0.10.10-dev.202607211734.3ee8a7b

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.10-dev.202607211537.40f1959",
3
+ "version": "0.10.10-dev.202607211734.3ee8a7b",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -98,6 +98,72 @@ describe("SendMessageOptions.config.overrideProfile", () => {
98
98
  expect(captured?.config?.callSite).toBe("conversationTitle");
99
99
  });
100
100
 
101
+ test("CallSiteConfiguredProvider forwards its stored overrideProfile when the caller sets callSite", async () => {
102
+ let captured: SendMessageOptions | undefined;
103
+ const inner: Provider = {
104
+ name: "anthropic",
105
+ async sendMessage(
106
+ _messages: Message[],
107
+ options?: SendMessageOptions,
108
+ ): Promise<ProviderResponse> {
109
+ captured = options;
110
+ return makeResponse("anthropic");
111
+ },
112
+ };
113
+
114
+ const provider = new CallSiteConfiguredProvider(
115
+ inner,
116
+ "inference",
117
+ "byok-sonnet",
118
+ );
119
+ await provider.sendMessage(DUMMY_MESSAGES, {
120
+ config: { callSite: "inference" },
121
+ });
122
+
123
+ // Naming a call site must not opt the caller out of profile propagation:
124
+ // the two fields are independent, and downstream resolution reads the
125
+ // override off the config it is handed.
126
+ expect(captured?.config?.overrideProfile).toBe("byok-sonnet");
127
+ });
128
+
129
+ test("a profile-pinned send resolves the profile's model, not the call-site default", async () => {
130
+ setLlmConfig({
131
+ profiles: {
132
+ "balanced-together": {
133
+ provider: "together",
134
+ model: "moonshotai/Kimi-K2-Instruct",
135
+ },
136
+ },
137
+ });
138
+
139
+ let captured: Record<string, unknown> | undefined;
140
+ const inner: Provider = {
141
+ name: "together",
142
+ async sendMessage(
143
+ _messages: Message[],
144
+ options?: SendMessageOptions,
145
+ ): Promise<ProviderResponse> {
146
+ captured = options?.config as Record<string, unknown> | undefined;
147
+ return makeResponse("together");
148
+ },
149
+ };
150
+
151
+ const provider = new CallSiteConfiguredProvider(
152
+ new RetryProvider(inner),
153
+ "inference",
154
+ "balanced-together",
155
+ );
156
+ await provider.sendMessage(DUMMY_MESSAGES, {
157
+ config: { callSite: "inference" },
158
+ });
159
+
160
+ // Losing the override strands a Together connection on the `inference`
161
+ // call-site default (`cost-optimized`), whose model is a Fireworks id —
162
+ // the provider half stays correct, so the upstream 400 names a model the
163
+ // caller never chose.
164
+ expect(captured?.model).toBe("moonshotai/Kimi-K2-Instruct");
165
+ });
166
+
101
167
  test("RetryProvider resolves model from named profile when overrideProfile is set", async () => {
102
168
  setLlmConfig({
103
169
  profiles: {
@@ -357,6 +357,25 @@ describe("QdrantManager", () => {
357
357
  // THEN the error includes the stderr output
358
358
  await expect(mgr.start()).rejects.toThrow("storage corrupted");
359
359
  }, 10_000);
360
+
361
+ test("includes stdout in error when process crashes", async () => {
362
+ // GIVEN a binary that reports its failure on stdout, as Qdrant does for
363
+ // panics, while stderr carries only unrelated allocator noise
364
+ placeFakeBinary(
365
+ '#!/bin/sh\necho "<jemalloc>: option background_thread currently supports pthread only" >&2\n' +
366
+ 'echo "Panic occurred: Failed to load local shard"\nexit 101',
367
+ );
368
+
369
+ const port = getTestPort();
370
+ const mgr = new QdrantManager({
371
+ url: `http://127.0.0.1:${port}`,
372
+ ...FAST_TIMEOUTS,
373
+ });
374
+
375
+ // WHEN we start the manager
376
+ // THEN the error carries the stdout explanation, not just the noise
377
+ await expect(mgr.start()).rejects.toThrow("Failed to load local shard");
378
+ }, 10_000);
360
379
  });
361
380
 
362
381
  // ── Binary Detection ─────────────────────────────────────────
@@ -26,6 +26,13 @@ const READYZ_POLL_INTERVAL_MS = 200;
26
26
  const READYZ_TIMEOUT_MS = 30_000;
27
27
  const SHUTDOWN_GRACE_MS = 5_000;
28
28
 
29
+ // Qdrant routes its own logging to stdout, including the panic reports its
30
+ // panic hook emits on a failed start. Stderr only ever carries the jemalloc
31
+ // allocator notice printed before Qdrant's logging initializes, so stdout is
32
+ // where a startup failure actually explains itself and needs the larger cap.
33
+ const STDOUT_CAPTURE_LIMIT = 16_384;
34
+ const STDERR_CAPTURE_LIMIT = 4_096;
35
+
29
36
  export interface QdrantManagerConfig {
30
37
  url: string;
31
38
  storagePath?: string;
@@ -50,8 +57,9 @@ export interface QdrantManagerConfig {
50
57
  */
51
58
  export class QdrantManager {
52
59
  private process: Subprocess | null = null;
60
+ private stdoutBuffer = "";
53
61
  private stderrBuffer = "";
54
- private stderrDrained: Promise<void> = Promise.resolve();
62
+ private outputDrained: Promise<void> = Promise.resolve();
55
63
  private readonly url: string;
56
64
  private readonly host: string;
57
65
  private readonly port: number;
@@ -116,11 +124,11 @@ export class QdrantManager {
116
124
  QDRANT__STORAGE__STORAGE_PATH: this.storagePath,
117
125
  QDRANT__LOG_LEVEL: "WARN",
118
126
  },
119
- stdout: "ignore",
127
+ stdout: "pipe",
120
128
  stderr: "pipe",
121
129
  });
122
130
  this.process = proc;
123
- this.drainStderrFrom(proc.stderr);
131
+ this.drainOutputFrom(proc.stdout, proc.stderr);
124
132
 
125
133
  if (this.process.pid) {
126
134
  this.writePid(this.process.pid);
@@ -160,6 +168,7 @@ export class QdrantManager {
160
168
  }
161
169
 
162
170
  this.process = null;
171
+ this.stdoutBuffer = "";
163
172
  this.stderrBuffer = "";
164
173
  this.cleanupPid();
165
174
  log.info("Qdrant stopped");
@@ -282,11 +291,10 @@ export class QdrantManager {
282
291
  : new Promise<ExitedOutcome>(() => {});
283
292
 
284
293
  const throwOnExit = async (code: number): Promise<never> => {
285
- await this.stderrDrained;
286
- const stderr = this.stderrBuffer.trim();
294
+ await this.outputDrained;
287
295
  throw new Error(
288
296
  `Qdrant process exited with code ${code} before becoming ready` +
289
- (stderr ? `\nstderr:\n${stderr}` : ""),
297
+ this.formatCapturedOutput(),
290
298
  );
291
299
  };
292
300
 
@@ -314,30 +322,68 @@ export class QdrantManager {
314
322
  ]);
315
323
  if (sleepOutcome.type === "exited") await throwOnExit(sleepOutcome.code);
316
324
  }
317
- const stderr = this.stderrBuffer.trim();
318
325
  throw new Error(
319
326
  `Qdrant did not become ready within ${this.readyzTimeoutMs}ms at ${this.url}` +
320
- (stderr ? `\nstderr:\n${stderr}` : ""),
327
+ this.formatCapturedOutput(),
321
328
  );
322
329
  }
323
330
 
324
- private drainStderrFrom(stream: ReadableStream<Uint8Array>): void {
331
+ private drainOutputFrom(
332
+ stdout: ReadableStream<Uint8Array>,
333
+ stderr: ReadableStream<Uint8Array>,
334
+ ): void {
335
+ // Both streams must be drained for the lifetime of the process, not just
336
+ // until startup settles. An unread pipe fills and then blocks Qdrant on its
337
+ // next write.
338
+ this.outputDrained = Promise.all([
339
+ this.drainStream(stdout, STDOUT_CAPTURE_LIMIT, (text) => {
340
+ this.stdoutBuffer = text;
341
+ }),
342
+ this.drainStream(stderr, STDERR_CAPTURE_LIMIT, (text) => {
343
+ this.stderrBuffer = text;
344
+ }),
345
+ ]).then(() => undefined);
346
+ }
347
+
348
+ /**
349
+ * Accumulates a stream into a bounded buffer, keeping the most recent
350
+ * `limit` characters. Qdrant prints the panic reason after the backtrace, so
351
+ * retaining the tail keeps the explanation and drops the frames above it.
352
+ */
353
+ private async drainStream(
354
+ stream: ReadableStream<Uint8Array>,
355
+ limit: number,
356
+ assign: (text: string) => void,
357
+ ): Promise<void> {
325
358
  const reader = stream.getReader();
326
359
  const decoder = new TextDecoder();
327
- this.stderrDrained = (async () => {
328
- try {
329
- for (;;) {
330
- const { done, value } = await reader.read();
331
- if (done) break;
332
- this.stderrBuffer += decoder.decode(value, { stream: true });
333
- if (this.stderrBuffer.length > 4096) {
334
- this.stderrBuffer = this.stderrBuffer.slice(-4096);
335
- }
360
+ let buffer = "";
361
+ try {
362
+ for (;;) {
363
+ const { done, value } = await reader.read();
364
+ if (done) break;
365
+ buffer += decoder.decode(value, { stream: true });
366
+ if (buffer.length > limit) {
367
+ buffer = buffer.slice(-limit);
336
368
  }
337
- } catch {
338
- // Stream closed or error — expected during shutdown
369
+ assign(buffer);
339
370
  }
340
- })();
371
+ } catch {
372
+ // Stream closed or errored, which is expected during shutdown
373
+ }
374
+ }
375
+
376
+ /**
377
+ * Renders whatever Qdrant printed for attachment to a startup error. Stdout
378
+ * leads because that is where Qdrant explains itself.
379
+ */
380
+ private formatCapturedOutput(): string {
381
+ const stdout = this.stdoutBuffer.trim();
382
+ const stderr = this.stderrBuffer.trim();
383
+ return (
384
+ (stdout ? `\nstdout:\n${stdout}` : "") +
385
+ (stderr ? `\nstderr:\n${stderr}` : "")
386
+ );
341
387
  }
342
388
 
343
389
  private getBinaryPath(): string {
@@ -23,7 +23,6 @@ import {
23
23
  renderCapabilityContent,
24
24
  } from "../v3/capabilities.js";
25
25
  import { buildEdgeGraph } from "../v3/edge.js";
26
- import { computeLearnedEdgeGraph } from "../v3/learned-edges.js";
27
26
  import {
28
27
  getPageIndex,
29
28
  type PageIndexEntry,
@@ -44,9 +43,6 @@ import type {
44
43
  MemoryGraphNodeDetail,
45
44
  } from "./types.js";
46
45
 
47
- const DAY_MS = 24 * 60 * 60 * 1000;
48
- /** Matches the selection window the v3 shadow lanes read for learned edges. */
49
- const LEARNED_EDGES_WINDOW_DAYS = 90;
50
46
  /** Backend identifier stamped onto graphs produced from memory-v3. */
51
47
  const BACKEND_MEMORY_V3 = "memory-v3";
52
48
  /**
@@ -55,18 +51,6 @@ const BACKEND_MEMORY_V3 = "memory-v3";
55
51
  * are kept and `truncated` is set.
56
52
  */
57
53
  const DEFAULT_MAX_NODES = 750;
58
- /**
59
- * Viz-density scaling of the retrieval lane's learned-edges thresholds. The
60
- * graph deliberately admits weaker co-selection associations than retrieval
61
- * (half the pair-count requirement, 40% of the NPMI floor, and at least
62
- * {@link GRAPH_LEARNED_MIN_MAX_PER_PAGE} neighbors per page) so it reads as a
63
- * connected web instead of scattered orphans. Retuning
64
- * `memory.v3.learnedEdges` for retrieval quality therefore also shifts graph
65
- * density — by these factors.
66
- */
67
- const GRAPH_LEARNED_MIN_COUNT_FACTOR = 0.5;
68
- const GRAPH_LEARNED_NPMI_FLOOR_FACTOR = 0.4;
69
- const GRAPH_LEARNED_MIN_MAX_PER_PAGE = 14;
70
54
 
71
55
  /** Adjacency as produced by `buildEdgeGraph` / `computeLearnedEdgeGraph`:
72
56
  * source → (target → curated description | undefined). */
@@ -280,25 +264,12 @@ export async function getMemoryGraph(
280
264
  hubDegree: config.memory.v3.edge.hubDegree,
281
265
  });
282
266
 
283
- // Viz-tuned learned edges (see the GRAPH_LEARNED_* constants): this endpoint
284
- // is visualization-only, so surfacing weaker co-selection associations (and a
285
- // little extra edge noise) is a fair trade. Floors keep the thresholds sane
286
- // even when the retrieval config is aggressive or disables the lane.
287
- const learned = config.memory.v3.learnedEdges;
288
- const learnedGraph = computeLearnedEdgeGraph({
289
- halfLifeMs: learned.halfLifeDays * DAY_MS,
290
- minCount: Math.max(1, learned.minCount * GRAPH_LEARNED_MIN_COUNT_FACTOR),
291
- npmiFloor: Math.max(0, learned.npmiFloor * GRAPH_LEARNED_NPMI_FLOOR_FACTOR),
292
- maxPerPage: Math.max(learned.maxPerPage, GRAPH_LEARNED_MIN_MAX_PER_PAGE),
293
- now: Date.now(),
294
- windowMs: LEARNED_EDGES_WINDOW_DAYS * DAY_MS,
295
- knownSlugs: new Set(entries.map((e) => e.slug)),
296
- });
297
-
267
+ // The graph surfaces only authored `link` edges; learned (co-selection)
268
+ // associations are intentionally omitted here. assembleMemoryGraph accepts an
269
+ // optional learned adjacency, but this endpoint does not build one.
298
270
  const assembled = assembleMemoryGraph({
299
271
  entries,
300
272
  staticAdjacency: staticGraph.adjacency,
301
- learnedAdjacency: learnedGraph.adjacency,
302
273
  });
303
274
 
304
275
  // Buffer entries awaiting consolidation ride along as `pending` nodes so a
@@ -77,15 +77,15 @@ export class CallSiteConfiguredProvider implements Provider {
77
77
  options?: SendMessageOptions,
78
78
  ): Promise<ProviderResponse> {
79
79
  const config = options?.config;
80
- if (config?.callSite) {
81
- return this.inner.sendMessage(messages, options);
82
- }
83
-
80
+ // Each field falls back independently. Naming a call site per-call must
81
+ // not suppress the stored override — they are orthogonal, and dropping
82
+ // the override leaves the transport bound to the requested profile while
83
+ // the model resolves from the call-site default.
84
84
  return this.inner.sendMessage(messages, {
85
85
  ...options,
86
86
  config: {
87
87
  ...config,
88
- callSite: this.callSite,
88
+ callSite: config?.callSite ?? this.callSite,
89
89
  ...(config?.overrideProfile === undefined &&
90
90
  this.overrideProfile !== undefined
91
91
  ? { overrideProfile: this.overrideProfile }