@genesislcap/ai-assistant 15.111.2 → 15.111.3-GENC-2045.2
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/dist/ai-assistant.d.ts +37 -0
- package/dist/chat-driver.cjs +85 -9
- package/dist/chat-driver.cjs.map +2 -2
- package/dist/chat-driver.mjs +85 -9
- package/dist/chat-driver.mjs.map +2 -2
- package/dist/custom-elements.json +78 -2
- package/dist/dts/autopilot/decision-message.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts +37 -0
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/turn-failures.d.ts +10 -0
- package/dist/dts/components/chat-driver/turn-failures.d.ts.map +1 -1
- package/dist/dts/state/debug-event-log.d.ts.map +1 -1
- package/dist/dts/utils/preserved-user-messages.d.ts.map +1 -1
- package/dist/esm/autopilot/decision-message.js +2 -0
- package/dist/esm/components/chat-driver/chat-driver.js +74 -12
- package/dist/esm/components/chat-driver/turn-failures.js +27 -1
- package/dist/esm/state/debug-event-log.js +1 -0
- package/dist/esm/utils/preserved-user-messages.js +3 -1
- package/package.json +17 -17
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -3331,6 +3331,19 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
3331
3331
|
* children costing N doomed calls plus a doomed parent one.
|
|
3332
3332
|
*/
|
|
3333
3333
|
private providerRefusedThisTurn;
|
|
3334
|
+
/**
|
|
3335
|
+
* Where the current turn starts in `history`: the user message `sendMessage` appends, or the
|
|
3336
|
+
* first message a `continueFromHistory` adds. A refused turn is withdrawn from here (GENC-2045),
|
|
3337
|
+
* not from the last user message, because a continuation adds no user message, and a driver note
|
|
3338
|
+
* (a finish-guard or forced-tool nudge) is `role: 'user'` in the middle of a turn.
|
|
3339
|
+
*/
|
|
3340
|
+
private turnStartIndex;
|
|
3341
|
+
/**
|
|
3342
|
+
* The provider refused something this turn (its own answer, a closing call, or a sub-agent's),
|
|
3343
|
+
* so the turn is withdrawn from the provider history when it ends. Read once, in the `finally`
|
|
3344
|
+
* of `sendMessage` and `continueFromHistory`.
|
|
3345
|
+
*/
|
|
3346
|
+
private withdrawTurnAtEnd;
|
|
3334
3347
|
/** The refusal detail latched off a sub-agent's failure, for the parent's own result. */
|
|
3335
3348
|
private providerRefusedDetail?;
|
|
3336
3349
|
/** Host overrides for the AI service error sentences (`ChatDriverConfig.aiServiceErrorMessages`). */
|
|
@@ -4161,6 +4174,30 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
4161
4174
|
* turn content and the model must keep seeing them.
|
|
4162
4175
|
*/
|
|
4163
4176
|
private appendDriverNotice;
|
|
4177
|
+
/**
|
|
4178
|
+
* A child the model refused (GENC-2045). It was handed this driver's history, so the refused
|
|
4179
|
+
* content is in the parent's history too, and every later delegation would inherit it and be
|
|
4180
|
+
* refused again. The turn goes on, since the handler may recover, and is withdrawn when it ends.
|
|
4181
|
+
* A method of its own to keep `invokeSubAgent` under the complexity ceiling.
|
|
4182
|
+
*/
|
|
4183
|
+
private noteChildRefusal;
|
|
4184
|
+
/**
|
|
4185
|
+
* Withdraws the turn that just ended from what the provider is sent, when the provider refused
|
|
4186
|
+
* something in it (GENC-2045). Flags every message from the turn's start `excludeFromProvider`,
|
|
4187
|
+
* so the next request no longer carries what was refused. The turn's tool calls and results are
|
|
4188
|
+
* flagged together, so none is left without the other. Nothing is removed from the history: the
|
|
4189
|
+
* UI and the debug log still show the turn.
|
|
4190
|
+
*
|
|
4191
|
+
* The cost: the model's next turn has no record of what the withdrawn turn did. A tool it ran
|
|
4192
|
+
* (a file written, a state transition, an interaction the user answered) has taken effect, but
|
|
4193
|
+
* the model is not told. It may repeat that work, or contradict what is on screen. A short note
|
|
4194
|
+
* of the completed tools would have to reach the provider as a message of its own, with the role
|
|
4195
|
+
* alternation that implies, so it is not done here. The refused content is what must not be sent.
|
|
4196
|
+
*
|
|
4197
|
+
* Only the top-level driver does this. A sub-agent that is refused reports `refusal` to its
|
|
4198
|
+
* parent (`invokeSubAgent`), which withdraws its own turn.
|
|
4199
|
+
*/
|
|
4200
|
+
private withdrawRefusedTurn;
|
|
4164
4201
|
private appendToHistory;
|
|
4165
4202
|
/** Announce the current history to the host. */
|
|
4166
4203
|
private notifyHistoryUpdated;
|
package/dist/chat-driver.cjs
CHANGED
|
@@ -5349,6 +5349,7 @@ var DEBUG_LOG_README = [
|
|
|
5349
5349
|
"kind:'message' \u2014 the conversation. `role` is user/assistant/tool/system-event/synthetic-user; `agentName` says which agent produced it; `toolCalls`/`toolResult`/`interaction` carry tool and widget activity; `inputTokens`/`outputTokens`/`cost` are per-message LLM usage, where `inputTokens` is the WHOLE prompt for that request and `cacheReadTokens`/`cacheWriteTokens` BREAK IT DOWN rather than add to it \u2014 uncached input is `inputTokens` minus those two, and adding the cache fields to `inputTokens` counts the prompt twice. The cache fields are absent on providers that report no cache split (Gemini reports reads only, since implicit caching bills no write) and on messages persisted before they existed, so read them as 0 when missing. Each bucket bills at a different rate \u2014 cache reads a fraction of uncached input, cache writes a premium, output highest \u2014 so a large token count at a small cost means the prompt was mostly cache hits. `externalCostUsd` is any non-LLM cost a widget reported for its own external service calls (folded into the session cost total alongside `cost`). On model-produced assistant messages, `model` is the concrete model id that generated it (e.g. 'gemini-2.5-flash-lite') and `providerName` is the registry slot it resolved under (e.g. a tier name like 'high'/'low', or the default); together they attribute the message \u2014 and any tool calls it carries \u2014 to an exact model even across a mid-session vendor/tier switch, where one slot name can map to different models before and after the switch. Both are undefined on any entry that is NOT an LLM response: non-assistant roles (user/tool/system-event) and 'synthetic-user' echoes; assistant interaction/widget entries (empty content carrying an `interaction` \u2014 a rendered widget, not a model turn); driver-authored assistant fallbacks (the timeout, repeated-malformed-call, and empty-response apology messages); and messages restored from a session persisted before these fields existed. One partial case: on a genuine model turn whose provider exposes no `getStatus` (or reports no model), `providerName` is still set but `model` alone is undefined. A 'synthetic-user' message is a display-only echo of an interaction outcome (e.g. the answer a widget reported): it renders on the user's side of the chat and `agentName` is the agent that created it, but it is never sent to the LLM \u2014 so it has no matching 'turn' and the model learns the outcome only from the corresponding tool result. An echo of an answer an interceptor (such as an autopilot) gave is NOT synthetic-user: see the delegated-messages paragraph.",
|
|
5350
5350
|
"The autopilot (GENC-1660) runs on a driver of its own, and everything it did is harvested into this log: entries with delegate: autopilot and an agentName ending in \u203A Autopilot are its turns (the decision message it was sent is the user message of its turn, so what it was shown is there verbatim; its systemPrompt is its grounding, such as the brief), its tool calls (widget_read, widget_act, hand_back, any read-only tools of its own, and its widget tools \u2014 reads with parameters that a widget type declares, routed to the interaction of that type being decided and refused with a reason when none is, offered on every decision so its tool list never changes; while one is open its tail starts with a line naming them) and their results (a read, view or widget tool, is capped at about 20,000 characters, cut with a note asking for less, and leaves its history at the end of the decision as a one-line note), and its own events. Its cost is already in the session total: it is booked as externalCostUsd on the interaction each decision answered, or, for a written question it answered, on the user message it sent on the user behalf (delegate: autopilot), so do not add its turns to that total. Spend that reached no message is recorded as autopilot.cost-dropped instead.",
|
|
5351
5351
|
"Delegated messages (GENC-1660): a message with a `delegate` field was written or sent ON THE USER'S BEHALF by a driver decorator, and `delegate` names it (e.g. autopilot). The platform stamps it; nothing else can. It renders as the assistant whatever its role. A delegated `user` message was NOT typed by the user: it is an answer given on their behalf, and the model read it with `delegateFraming` in brackets in front of the content (the stored `content` is the bare text). A delegated `assistant` message is display-only (`excludeFromProvider`): the decorator's narration note, or, when its answer carried no note, the widget's own echo of the answer (its `userMessage`), shown as the assistant and never as the person. A widget answer a decorator gave with a note is not echoed at all: the note already says what was chosen. To tell what the person decided from what was decided for them, read `interaction.answeredBy` and these fields, never the role alone. Driver notes: a `user` message with a `driverNote` field was written by the driver for the model, never by the user, and is hidden from the transcript; `driverNote: 'finish-guard'` is the agent's finishGuard holding the turn open after a prose reply, its content the guard's note in a `<system-reminder>`, and it follows a turn.finish-guard event; `driverNote: 'completion-nudge'` is the driver asking a sub-agent that replied in prose to call its completion tool; `driverNote: 'forced-tool-nudge'` is the driver asking a parent agent for the tool call its forced turn required, after a model that rejects forcing (responseMeta.toolChoiceDowngraded) replied in prose.",
|
|
5352
|
+
"`excludeFromProvider` (GENC-2045): the message is in this log and the transcript, but was NOT sent to the model. The driver's own notices carry it, and so does a turn the provider refused: the user's prompt, and the tool calls and results that followed it, so one refusal is not sent again with every later request. A flagged `user` message is something the user really said; it just no longer reaches the model.",
|
|
5352
5353
|
"Sub-agent messages appear inline. When a tool delegates to a sub-agent (via `requestSubAgent`), the sub-agent's whole conversation \u2014 its own assistant/tool messages, each with their own `content`/`thinking`/`toolCalls`/`toolResult` and per-message `model`/`providerName`/`inputTokens`/`outputTokens`/`cacheReadTokens`/`cacheWriteTokens`/`cost` \u2014 is hoisted into the timeline as ordinary kind:'message' entries, interleaved by timestamp right after the tool call that spawned them (so you read the delegation top-to-bottom). A hoisted entry is marked: `subAgentDepth` is its delegation depth (1 for a sub-agent, 2 for a sub-agent's sub-agent, \u2026), `subAgentOf` is the id of the parent tool call that spawned it (correlates it back even when two sub-agents run in one parent turn), `subAgentName` is the sub-agent's own name, and `agentName` is rewritten to a `\"<parent> \u203A <sub-agent>\"` breadcrumb (composing when nested, e.g. `\"UI Builder \u203A Planner \u203A Grounding\"`). The sub-agent's per-LLM-call snapshots also surface as kind:'turn' entries with a `<parentTurn>-<subAgentNo>.<childTurn>` `turnIndex` (see the kind:'turn' paragraph), and subagent.started/completed (or subagent.failed) events bracket the run. Per-message `cost` on hoisted entries is already part of the session total (it is summed from the un-flattened history), so summing the top-level timeline does NOT double-count.",
|
|
5353
5354
|
"kind:'turn' \u2014 one LLM call. `turnIndex` is a string: a top-level turn is the bare counter ('0', '1', \u2026); a sub-agent's turns are labelled '<parentTurn>-<subAgentNo>.<childTurn>': the parent turn that activated it, the sub-agent's number (1-based, in the order the sub-agents started within that parent turn, so it matches the order of the subagent.started events; two sub-agents in one parent turn never share a number, even when they run in parallel or share a name), and the sub-agent's own turn position (1-based) \u2014 e.g. '3-2.1', '3-2.2' are the first two turns of the second sub-agent started in parent turn 3, and a sub-agent nested under its turn '3-2.2' contributes '3-2.2-1.1', \u2026 ('.' joins the parts of one level, '-' separates levels). The `<parentTurn>-<subAgentNo>` part is the sub-agent's `turnPrefix`: the same value is stamped on its subagent.started/completed/failed events and on its harvested events as `detail.turnPrefix`, so match events to turns by value (a turn belongs to the sub-agent whose `turnPrefix` its `turnIndex` begins with) \u2014 and `agentName` names the agent that ran the turn. `systemPrompt` and `toolNames` are what the model saw. A systemPrompt of '<repeated \u2014 identical to turn N>' was byte-identical to turn N and de-duplicated; the full prompt is shown whenever it changes (often because a stateful agent advanced), so prompt evolution is visible.",
|
|
5354
5355
|
"kind:'turn'.`model`/`providerName`/`provider` \u2014 which model ran that call: the concrete model id, the registry slot it resolved under (a tier name like 'high'/'low', or the default), and the vendor. Recorded per CALL, so an agent whose `provider` selector varies by state \u2014 a flow that plans on a high tier and executes on a low one \u2014 has every step attributed, including calls that produced no message. `model` is the SERVING model where the provider reports one, so a turn answered by a server-side fallback names the model that answered rather than the one requested; it always matches the `model` on the message that call produced. Absent when the provider exposes no `getStatus` and the transport stamped nothing.",
|
|
@@ -5398,13 +5399,17 @@ ${note.trim()}
|
|
|
5398
5399
|
// src/utils/preserved-user-messages.ts
|
|
5399
5400
|
function freshUserMessages(toCompact) {
|
|
5400
5401
|
return toCompact.flatMap(
|
|
5401
|
-
(m) =>
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5402
|
+
(m) => (
|
|
5403
|
+
// A prompt the provider refused is withdrawn (`excludeFromProvider`); keeping it here would put
|
|
5404
|
+
// it back in the request word for word (GENC-2045).
|
|
5405
|
+
isUserUtterance(m) && !m.excludeFromProvider && m.content?.trim() ? [
|
|
5406
|
+
{
|
|
5407
|
+
content: m.content,
|
|
5408
|
+
...m.timestamp ? { timestamp: m.timestamp } : {},
|
|
5409
|
+
...m.delegate ? { delegate: m.delegate, delegateFraming: m.delegateFraming } : {}
|
|
5410
|
+
}
|
|
5411
|
+
] : []
|
|
5412
|
+
)
|
|
5408
5413
|
);
|
|
5409
5414
|
}
|
|
5410
5415
|
var preservedUserLine = (u) => `User: ${u.delegate ? frameDelegatedContent(u.content, u.delegateFraming) : u.content}`;
|
|
@@ -8060,7 +8065,7 @@ var TURN_FAILURE_EXITS = {
|
|
|
8060
8065
|
refusal: {
|
|
8061
8066
|
subReason: "refusal",
|
|
8062
8067
|
resultReason: "refusal",
|
|
8063
|
-
copy: "
|
|
8068
|
+
copy: "The AI provider declined this request. It won't be sent again with your next messages. If replies keep being declined, start a new conversation."
|
|
8064
8069
|
},
|
|
8065
8070
|
emptyResponse: {
|
|
8066
8071
|
subReason: "empty_response",
|
|
@@ -8101,6 +8106,20 @@ function turnDone(failureReason, budget, providerRefused) {
|
|
|
8101
8106
|
...providerRefused ? { providerRefused } : {}
|
|
8102
8107
|
};
|
|
8103
8108
|
}
|
|
8109
|
+
var REFUSAL_FINISH_REASONS = /* @__PURE__ */ new Set([
|
|
8110
|
+
"refusal",
|
|
8111
|
+
"content_filter",
|
|
8112
|
+
"safety",
|
|
8113
|
+
"prohibited_content",
|
|
8114
|
+
"blocklist",
|
|
8115
|
+
"spii",
|
|
8116
|
+
"image_safety"
|
|
8117
|
+
]);
|
|
8118
|
+
function isRefusalLike(meta) {
|
|
8119
|
+
if (!meta) return false;
|
|
8120
|
+
if (meta.blockReason) return true;
|
|
8121
|
+
return !!meta.finishReason && REFUSAL_FINISH_REASONS.has(meta.finishReason.toLowerCase());
|
|
8122
|
+
}
|
|
8104
8123
|
|
|
8105
8124
|
// src/components/chat-driver/turn-recorder.ts
|
|
8106
8125
|
function nestUnderSubAgent(prefix, key) {
|
|
@@ -8585,6 +8604,19 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
8585
8604
|
* children costing N doomed calls plus a doomed parent one.
|
|
8586
8605
|
*/
|
|
8587
8606
|
this.providerRefusedThisTurn = false;
|
|
8607
|
+
/**
|
|
8608
|
+
* Where the current turn starts in `history`: the user message `sendMessage` appends, or the
|
|
8609
|
+
* first message a `continueFromHistory` adds. A refused turn is withdrawn from here (GENC-2045),
|
|
8610
|
+
* not from the last user message, because a continuation adds no user message, and a driver note
|
|
8611
|
+
* (a finish-guard or forced-tool nudge) is `role: 'user'` in the middle of a turn.
|
|
8612
|
+
*/
|
|
8613
|
+
this.turnStartIndex = 0;
|
|
8614
|
+
/**
|
|
8615
|
+
* The provider refused something this turn (its own answer, a closing call, or a sub-agent's),
|
|
8616
|
+
* so the turn is withdrawn from the provider history when it ends. Read once, in the `finally`
|
|
8617
|
+
* of `sendMessage` and `continueFromHistory`.
|
|
8618
|
+
*/
|
|
8619
|
+
this.withdrawTurnAtEnd = false;
|
|
8588
8620
|
/**
|
|
8589
8621
|
* A sub-agent was refused by the AI service this turn in a way that stops this driver too
|
|
8590
8622
|
* (GENC-1611): a service-wide code, from the vendor this driver calls. Sub-agent path only, like
|
|
@@ -10112,6 +10144,8 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10112
10144
|
this.aiServiceWall = void 0;
|
|
10113
10145
|
this.aiServiceNoticesShown.clear();
|
|
10114
10146
|
this.aiServiceNoticesQueued = [];
|
|
10147
|
+
this.withdrawTurnAtEnd = false;
|
|
10148
|
+
this.turnStartIndex = this.history.length;
|
|
10115
10149
|
this.appendToHistory({
|
|
10116
10150
|
role: "user",
|
|
10117
10151
|
content: userInput,
|
|
@@ -10155,6 +10189,7 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10155
10189
|
});
|
|
10156
10190
|
this.busy = false;
|
|
10157
10191
|
this.endTurn();
|
|
10192
|
+
this.withdrawRefusedTurn();
|
|
10158
10193
|
this.activityBus.publish("tool-loop-end", this.loopEndDetail(result));
|
|
10159
10194
|
await this.releaseIfRequested();
|
|
10160
10195
|
}
|
|
@@ -10472,6 +10507,7 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10472
10507
|
this.providerRefusedThisTurn = true;
|
|
10473
10508
|
this.providerRefusedDetail ??= failure?.providerRefused;
|
|
10474
10509
|
}
|
|
10510
|
+
this.noteChildRefusal(reason);
|
|
10475
10511
|
const wall = failure?.aiServiceError;
|
|
10476
10512
|
if (reason === "ai_service_error" && wall && SERVICE_WIDE_REFUSALS.has(wall.code) && wall.vendor !== void 0 && wall.vendor === this.lastResolvedProvider) {
|
|
10477
10513
|
this.aiServiceErrorThisTurn = true;
|
|
@@ -10521,6 +10557,8 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10521
10557
|
this.providerRefusedDetail = void 0;
|
|
10522
10558
|
this.aiServiceErrorThisTurn = false;
|
|
10523
10559
|
this.aiServiceWall = void 0;
|
|
10560
|
+
this.withdrawTurnAtEnd = false;
|
|
10561
|
+
this.turnStartIndex = this.history.length;
|
|
10524
10562
|
this.turnStartedAt = Date.now();
|
|
10525
10563
|
recordMetaEvent(this.sessionKey, "turn.start", {
|
|
10526
10564
|
phase: "continueFromHistory",
|
|
@@ -10554,6 +10592,7 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
10554
10592
|
});
|
|
10555
10593
|
this.busy = false;
|
|
10556
10594
|
this.endTurn();
|
|
10595
|
+
this.withdrawRefusedTurn();
|
|
10557
10596
|
this.activityBus.publish("tool-loop-end", this.loopEndDetail(result));
|
|
10558
10597
|
await this.releaseIfRequested();
|
|
10559
10598
|
}
|
|
@@ -10907,13 +10946,14 @@ ${tailBody}
|
|
|
10907
10946
|
}
|
|
10908
10947
|
turnSnapshot.usage = messageUsage(response);
|
|
10909
10948
|
if (response.model !== void 0) turnSnapshot.model = response.model;
|
|
10949
|
+
if (isRefusalLike(response.responseMeta)) this.withdrawTurnAtEnd = true;
|
|
10910
10950
|
if (closing) {
|
|
10911
10951
|
if (response.toolCalls?.length) response = { ...response, toolCalls: void 0 };
|
|
10912
10952
|
if (!response.content?.trim()) return turnDone();
|
|
10913
10953
|
}
|
|
10914
10954
|
const isThinkingStep = response.content && response.toolCalls?.length;
|
|
10915
10955
|
const isEmptyResponse = !response.content?.trim() && !response.toolCalls?.length;
|
|
10916
|
-
const isRefusal = response.responseMeta
|
|
10956
|
+
const isRefusal = isRefusalLike(response.responseMeta);
|
|
10917
10957
|
if (isEmptyResponse) {
|
|
10918
10958
|
emptyResponseAttempts += 1;
|
|
10919
10959
|
if (!isRefusal && emptyResponseAttempts < MAX_EMPTY_RESPONSE_RETRIES) {
|
|
@@ -10940,6 +10980,7 @@ ${tailBody}
|
|
|
10940
10980
|
continue;
|
|
10941
10981
|
}
|
|
10942
10982
|
const exit = isRefusal ? TURN_FAILURE_EXITS.refusal : TURN_FAILURE_EXITS.emptyResponse;
|
|
10983
|
+
if (isRefusal) this.withdrawTurnAtEnd = true;
|
|
10943
10984
|
logger2.error(
|
|
10944
10985
|
isRefusal ? "ChatDriver: model refused the request (safety decline) \u2014 not retrying" : "ChatDriver: empty model response after all retries"
|
|
10945
10986
|
);
|
|
@@ -11388,6 +11429,40 @@ RECOVERY: this tool failed once \u2014 you may retry it, or take a different val
|
|
|
11388
11429
|
appendDriverNotice(content) {
|
|
11389
11430
|
this.appendToHistory({ role: "assistant", content, excludeFromProvider: true });
|
|
11390
11431
|
}
|
|
11432
|
+
/**
|
|
11433
|
+
* A child the model refused (GENC-2045). It was handed this driver's history, so the refused
|
|
11434
|
+
* content is in the parent's history too, and every later delegation would inherit it and be
|
|
11435
|
+
* refused again. The turn goes on, since the handler may recover, and is withdrawn when it ends.
|
|
11436
|
+
* A method of its own to keep `invokeSubAgent` under the complexity ceiling.
|
|
11437
|
+
*/
|
|
11438
|
+
noteChildRefusal(reason) {
|
|
11439
|
+
if (reason === "refusal") this.withdrawTurnAtEnd = true;
|
|
11440
|
+
}
|
|
11441
|
+
/**
|
|
11442
|
+
* Withdraws the turn that just ended from what the provider is sent, when the provider refused
|
|
11443
|
+
* something in it (GENC-2045). Flags every message from the turn's start `excludeFromProvider`,
|
|
11444
|
+
* so the next request no longer carries what was refused. The turn's tool calls and results are
|
|
11445
|
+
* flagged together, so none is left without the other. Nothing is removed from the history: the
|
|
11446
|
+
* UI and the debug log still show the turn.
|
|
11447
|
+
*
|
|
11448
|
+
* The cost: the model's next turn has no record of what the withdrawn turn did. A tool it ran
|
|
11449
|
+
* (a file written, a state transition, an interaction the user answered) has taken effect, but
|
|
11450
|
+
* the model is not told. It may repeat that work, or contradict what is on screen. A short note
|
|
11451
|
+
* of the completed tools would have to reach the provider as a message of its own, with the role
|
|
11452
|
+
* alternation that implies, so it is not done here. The refused content is what must not be sent.
|
|
11453
|
+
*
|
|
11454
|
+
* Only the top-level driver does this. A sub-agent that is refused reports `refusal` to its
|
|
11455
|
+
* parent (`invokeSubAgent`), which withdraws its own turn.
|
|
11456
|
+
*/
|
|
11457
|
+
withdrawRefusedTurn() {
|
|
11458
|
+
if (!this.withdrawTurnAtEnd || this.isSubAgent) return;
|
|
11459
|
+
this.withdrawTurnAtEnd = false;
|
|
11460
|
+
const start = Math.min(this.turnStartIndex, this.history.length);
|
|
11461
|
+
this.history = this.history.map(
|
|
11462
|
+
(m, i) => i >= start && !m.excludeFromProvider ? { ...m, excludeFromProvider: true } : m
|
|
11463
|
+
);
|
|
11464
|
+
this.notifyHistoryUpdated();
|
|
11465
|
+
}
|
|
11391
11466
|
appendToHistory(message) {
|
|
11392
11467
|
const tagged = {
|
|
11393
11468
|
...message,
|
|
@@ -13101,6 +13176,7 @@ function visibleTranscript(messages, opts) {
|
|
|
13101
13176
|
return;
|
|
13102
13177
|
}
|
|
13103
13178
|
if (isDriverNote(m)) return;
|
|
13179
|
+
if (m.excludeFromProvider && m.role === "user") return;
|
|
13104
13180
|
if ((m.role === "user" || m.role === "synthetic-user") && m.content?.trim()) {
|
|
13105
13181
|
lines.push(m.delegate ? `User (on their behalf): ${m.content}` : `User: ${m.content}`);
|
|
13106
13182
|
return;
|