@genesislcap/ai-assistant 15.78.1 → 15.79.0

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.
@@ -2410,7 +2410,12 @@ var AnthropicTransport = class _AnthropicTransport {
2410
2410
  * Append never-stored tail context (already framed by the caller) as the final block of the
2411
2411
  * outbound messages. Called AFTER `applyCacheControl`, so any `'history'` breakpoint sits
2412
2412
  * on the last *stored* block and this per-turn volatile block stays outside the cached prefix.
2413
- * At a model-call the last message is user-role; if not (defensive), start a fresh user turn.
2413
+ *
2414
+ * Joins the last message when it is user-role (a new user message, or tool results). Otherwise
2415
+ * it opens a user turn of its own, and that is not a defensive branch: a continuation with no
2416
+ * user input — every ai-assistant agent handoff — reaches here with history ending on an
2417
+ * assistant turn, and this block is what keeps the request from ending there, which Anthropic
2418
+ * refuses as a prefill.
2414
2419
  */
2415
2420
  appendTailContext(body, tailContext) {
2416
2421
  const block = { type: "text", text: tailContext };
@@ -9480,6 +9485,13 @@ Politely let the user know what you can help with and invite them to rephrase th
9480
9485
 
9481
9486
  ${UNROUTABLE_INSTRUCTION}`;
9482
9487
  }
9488
+ function handoffTailNote(agent, remainingTask) {
9489
+ if (isFallback(agent)) {
9490
+ return "[Hand-off]: no specialist here can take on what remains. Reply to the user now, as the routing note says.";
9491
+ }
9492
+ const work = remainingTask?.trim();
9493
+ return work ? `[Hand-off]: the previous agent passed the rest of this request to you. What remains: ${work}` : "[Hand-off]: the previous agent passed the rest of this request to you without saying what remains. Carry on with the user's request above.";
9494
+ }
9483
9495
  var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator {
9484
9496
  constructor(providerRegistry, agents, options = {}) {
9485
9497
  super(_OrchestratingDriver.createInner(providerRegistry, agents, options));
@@ -9602,6 +9614,7 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
9602
9614
  detail: [...history, { role: "user", content: input, attachments, ...delegated }]
9603
9615
  })
9604
9616
  );
9617
+ const routingInput = delegated.delegate ? frameDelegatedContent(input, delegated.delegateFraming) : input;
9605
9618
  const pinned = this.resolvePinnedAgent();
9606
9619
  if (!pinned) this.dispatchEvent(new CustomEvent("orchestrating-start"));
9607
9620
  let routed;
@@ -9609,11 +9622,7 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
9609
9622
  this.recordRouting("pinned", pinned, { durationMs: 0 });
9610
9623
  routed = { agent: pinned, decision: "pinned" };
9611
9624
  } else {
9612
- routed = await this.classify(
9613
- delegated.delegate ? frameDelegatedContent(input, delegated.delegateFraming) : input,
9614
- history,
9615
- this.activeAgent
9616
- );
9625
+ routed = await this.classify(routingInput, history, this.activeAgent);
9617
9626
  }
9618
9627
  let currentAgent = routed.agent;
9619
9628
  let isHandoff = false;
@@ -9637,7 +9646,9 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
9637
9646
  ` : "[Routing note]: no specialist is available for the work that remains.\n") + "Tell the user plainly what was established, that this part falls outside what any specialist here can do, and what they could do next. Do not claim you will do it yourself, and do not return an empty response."
9638
9647
  });
9639
9648
  }
9640
- result = await this.chatDriver.continueFromHistory(contextPrimer);
9649
+ result = await this.chatDriver.continueFromHistory(contextPrimer, {
9650
+ tailNote: handoffTailNote(currentAgent, remainingTask)
9651
+ });
9641
9652
  } else {
9642
9653
  this.userMessageAppended = true;
9643
9654
  result = await this.chatDriver.sendMessage(input, attachments, options);
@@ -9666,7 +9677,12 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
9666
9677
  }
9667
9678
  const updatedHistory = this.chatDriver.getHistory();
9668
9679
  this.dispatchEvent(new CustomEvent("orchestrating-start"));
9669
- routed = await this.classify(remainingTask, updatedHistory, void 0, attempted);
9680
+ routed = await this.classify(
9681
+ remainingTask?.trim() || routingInput,
9682
+ updatedHistory,
9683
+ void 0,
9684
+ attempted
9685
+ );
9670
9686
  currentAgent = routed.agent;
9671
9687
  }
9672
9688
  if (this.cancelled && !this.userMessageAppended) {