@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.
@@ -2493,7 +2493,12 @@ var AnthropicTransport = class _AnthropicTransport {
2493
2493
  * Append never-stored tail context (already framed by the caller) as the final block of the
2494
2494
  * outbound messages. Called AFTER `applyCacheControl`, so any `'history'` breakpoint sits
2495
2495
  * on the last *stored* block and this per-turn volatile block stays outside the cached prefix.
2496
- * At a model-call the last message is user-role; if not (defensive), start a fresh user turn.
2496
+ *
2497
+ * Joins the last message when it is user-role (a new user message, or tool results). Otherwise
2498
+ * it opens a user turn of its own, and that is not a defensive branch: a continuation with no
2499
+ * user input — every ai-assistant agent handoff — reaches here with history ending on an
2500
+ * assistant turn, and this block is what keeps the request from ending there, which Anthropic
2501
+ * refuses as a prefill.
2497
2502
  */
2498
2503
  appendTailContext(body, tailContext) {
2499
2504
  const block = { type: "text", text: tailContext };
@@ -9563,6 +9568,13 @@ Politely let the user know what you can help with and invite them to rephrase th
9563
9568
 
9564
9569
  ${UNROUTABLE_INSTRUCTION}`;
9565
9570
  }
9571
+ function handoffTailNote(agent, remainingTask) {
9572
+ if (isFallback(agent)) {
9573
+ return "[Hand-off]: no specialist here can take on what remains. Reply to the user now, as the routing note says.";
9574
+ }
9575
+ const work = remainingTask?.trim();
9576
+ 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.";
9577
+ }
9566
9578
  var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator {
9567
9579
  constructor(providerRegistry, agents, options = {}) {
9568
9580
  super(_OrchestratingDriver.createInner(providerRegistry, agents, options));
@@ -9685,6 +9697,7 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
9685
9697
  detail: [...history, { role: "user", content: input, attachments, ...delegated }]
9686
9698
  })
9687
9699
  );
9700
+ const routingInput = delegated.delegate ? frameDelegatedContent(input, delegated.delegateFraming) : input;
9688
9701
  const pinned = this.resolvePinnedAgent();
9689
9702
  if (!pinned) this.dispatchEvent(new CustomEvent("orchestrating-start"));
9690
9703
  let routed;
@@ -9692,11 +9705,7 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
9692
9705
  this.recordRouting("pinned", pinned, { durationMs: 0 });
9693
9706
  routed = { agent: pinned, decision: "pinned" };
9694
9707
  } else {
9695
- routed = await this.classify(
9696
- delegated.delegate ? frameDelegatedContent(input, delegated.delegateFraming) : input,
9697
- history,
9698
- this.activeAgent
9699
- );
9708
+ routed = await this.classify(routingInput, history, this.activeAgent);
9700
9709
  }
9701
9710
  let currentAgent = routed.agent;
9702
9711
  let isHandoff = false;
@@ -9720,7 +9729,9 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
9720
9729
  ` : "[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."
9721
9730
  });
9722
9731
  }
9723
- result = await this.chatDriver.continueFromHistory(contextPrimer);
9732
+ result = await this.chatDriver.continueFromHistory(contextPrimer, {
9733
+ tailNote: handoffTailNote(currentAgent, remainingTask)
9734
+ });
9724
9735
  } else {
9725
9736
  this.userMessageAppended = true;
9726
9737
  result = await this.chatDriver.sendMessage(input, attachments, options);
@@ -9749,7 +9760,12 @@ var OrchestratingDriver = class _OrchestratingDriver extends BaseDriverDecorator
9749
9760
  }
9750
9761
  const updatedHistory = this.chatDriver.getHistory();
9751
9762
  this.dispatchEvent(new CustomEvent("orchestrating-start"));
9752
- routed = await this.classify(remainingTask, updatedHistory, void 0, attempted);
9763
+ routed = await this.classify(
9764
+ remainingTask?.trim() || routingInput,
9765
+ updatedHistory,
9766
+ void 0,
9767
+ attempted
9768
+ );
9753
9769
  currentAgent = routed.agent;
9754
9770
  }
9755
9771
  if (this.cancelled && !this.userMessageAppended) {