@vellumai/assistant 0.10.0-dev.202606230530.bc0f32e → 0.10.0-dev.202606230727.0d65a6b
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
|
@@ -2327,6 +2327,7 @@ describe("AgentLoop", () => {
|
|
|
2327
2327
|
messages: [userMessage],
|
|
2328
2328
|
onEvent: collectEvents(events),
|
|
2329
2329
|
trust: { sourceChannel: "vellum", trustClass: "unknown" },
|
|
2330
|
+
callSite: "mainAgent",
|
|
2330
2331
|
});
|
|
2331
2332
|
|
|
2332
2333
|
// Provider should be called 3 times: initial, empty response, retry
|
|
@@ -2410,6 +2411,7 @@ describe("AgentLoop", () => {
|
|
|
2410
2411
|
messages: [userMessage],
|
|
2411
2412
|
onEvent: collectEvents(events),
|
|
2412
2413
|
trust: { sourceChannel: "vellum", trustClass: "unknown" },
|
|
2414
|
+
callSite: "mainAgent",
|
|
2413
2415
|
});
|
|
2414
2416
|
|
|
2415
2417
|
// Provider called exactly 2 times: initial [text+tool_use], then empty.
|
|
@@ -2477,6 +2479,7 @@ describe("AgentLoop", () => {
|
|
|
2477
2479
|
messages: [userMessage],
|
|
2478
2480
|
onEvent: collectEvents(events),
|
|
2479
2481
|
trust: { sourceChannel: "vellum", trustClass: "unknown" },
|
|
2482
|
+
callSite: "mainAgent",
|
|
2480
2483
|
});
|
|
2481
2484
|
|
|
2482
2485
|
// Provider called 3 times: initial, empty, retry (also empty)
|
|
@@ -326,6 +326,48 @@ describe("empty-response post-model-call hook — default decisions", () => {
|
|
|
326
326
|
expect(ctx.decision).toBe("stop");
|
|
327
327
|
expect(ctx.messages).toEqual([priorToolUseTurn]);
|
|
328
328
|
});
|
|
329
|
+
|
|
330
|
+
// ─── Call-site gating ──────────────────────────────────────────────────────
|
|
331
|
+
|
|
332
|
+
test("empty turn after tools on a non-mainAgent call site → stop, no nudge", async () => {
|
|
333
|
+
// GIVEN an empty-after-tools turn that would nudge on the user-facing reply,
|
|
334
|
+
// but the call site is a background one (a memory retrospective). There is
|
|
335
|
+
// no user awaiting a summary, so the re-query nudge must not fire.
|
|
336
|
+
const ctx = makeCtx({
|
|
337
|
+
callSite: "memoryRetrospective",
|
|
338
|
+
messages: [priorToolUseTurn],
|
|
339
|
+
content: [],
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// WHEN the hook runs.
|
|
343
|
+
await postModelCall(ctx);
|
|
344
|
+
|
|
345
|
+
// THEN the turn ends silently — no nudge appended, no re-query.
|
|
346
|
+
expect(ctx.decision).toBe("stop");
|
|
347
|
+
expect(ctx.messages).toEqual([priorToolUseTurn]);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
test("refusal on a non-mainAgent call site is still rewritten to the fallback", async () => {
|
|
351
|
+
// GIVEN a refusal with no visible text on a background call site. The
|
|
352
|
+
// call-site gate scopes only the re-query nudge; the refusal-rewrite is a
|
|
353
|
+
// user-facing terminal fallback for any consumer that reads the final text,
|
|
354
|
+
// so it stays ungated.
|
|
355
|
+
const ctx = makeCtx({
|
|
356
|
+
callSite: "memoryRetrospective",
|
|
357
|
+
messages: [],
|
|
358
|
+
content: [],
|
|
359
|
+
stopReason: "refusal",
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// WHEN the hook runs.
|
|
363
|
+
await postModelCall(ctx);
|
|
364
|
+
|
|
365
|
+
// THEN the empty refusal is still rewritten to the user-facing fallback.
|
|
366
|
+
expect(ctx.decision).toBe("stop");
|
|
367
|
+
expect(ctx.content).toEqual([
|
|
368
|
+
{ type: "text", text: REFUSAL_FALLBACK_TEXT },
|
|
369
|
+
]);
|
|
370
|
+
});
|
|
329
371
|
});
|
|
330
372
|
|
|
331
373
|
// ─── One-shot retry bound ────────────────────────────────────────────────────
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
* at least one prior assistant turn this run, and no earlier turn this run
|
|
17
17
|
* already delivered visible text. The hook re-queries the model with
|
|
18
18
|
* `NUDGE_TEXT` (a tool trail exists to summarize, so a retry can recover a
|
|
19
|
-
* real answer).
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* real answer). Main-agent turns only: background, subagent, and compaction
|
|
20
|
+
* calls have no user awaiting a summary, so per the post-model-call contract
|
|
21
|
+
* the nudge self-gates on {@link PostModelCallContext.callSite}. The retry is
|
|
22
|
+
* bounded to one pass per run by a one-shot per-conversation mark this hook
|
|
23
|
+
* sets; the sibling `stop` hook (see `./stop.ts`) clears it when the turn
|
|
24
|
+
* terminates, so the next run nudges afresh.
|
|
23
25
|
*
|
|
24
26
|
* Every other case leaves the decision at `"stop"` (the model said its piece,
|
|
25
27
|
* or there is nothing to act on).
|
|
@@ -146,6 +148,13 @@ const postModelCall: PluginHookFn<PostModelCallContext> = async (ctx) => {
|
|
|
146
148
|
!priorAssistantHadVisibleText;
|
|
147
149
|
|
|
148
150
|
if (isEmptyTurnAfterTools) {
|
|
151
|
+
// Only the user-facing reply gets the re-query nudge. Background, subagent,
|
|
152
|
+
// and compaction calls have no user awaiting a summary, and the
|
|
153
|
+
// post-model-call contract requires self-gating on call site to avoid
|
|
154
|
+
// re-querying them. The refusal-rewrite above is a user-facing terminal
|
|
155
|
+
// fallback, not a re-query, so it stays ungated.
|
|
156
|
+
if (ctx.callSite !== "mainAgent") return;
|
|
157
|
+
|
|
149
158
|
// Re-query once to recover a real answer. The one-shot per-conversation
|
|
150
159
|
// mark makes the hook self-limiting: a second empty turn this run finds the
|
|
151
160
|
// mark already set and lets the turn end rather than nudging again.
|