@genesislcap/ai-assistant 14.454.2 → 14.455.1
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.api.json +336 -3
- package/dist/ai-assistant.d.ts +100 -0
- package/dist/dts/components/chat-driver/chat-driver.d.ts +30 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.test.d.ts.map +1 -1
- package/dist/dts/config/config.d.ts +45 -2
- package/dist/dts/config/config.d.ts.map +1 -1
- package/dist/dts/config/define-stateful-agent.d.ts +16 -1
- package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +7 -0
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/esm/components/chat-driver/chat-driver.js +40 -19
- package/dist/esm/components/chat-driver/chat-driver.test.js +86 -0
- package/dist/esm/config/define-stateful-agent.js +20 -0
- package/dist/esm/main/main.js +5 -3
- package/dist/esm/state/debug-event-log.js +1 -1
- package/package.json +16 -16
- package/src/components/chat-driver/chat-driver.test.ts +114 -2
- package/src/components/chat-driver/chat-driver.ts +76 -7
- package/src/config/config.ts +49 -1
- package/src/config/define-stateful-agent.ts +58 -1
- package/src/main/main.ts +7 -1
- package/src/state/debug-event-log.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-driver.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat-driver.test.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.test.ts"],"names":[],"mappings":"AAkBA,OAAO,uBAAuB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChatInputDuringExecutionMode, ChatMessage, ChatToolDefinition, ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
2
|
-
export type { ChatInputDuringExecutionMode };
|
|
1
|
+
import type { ChatInputDuringExecutionMode, ChatMessage, ChatToolChoice, ChatToolDefinition, ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
2
|
+
export type { ChatInputDuringExecutionMode, ChatToolChoice };
|
|
3
3
|
/**
|
|
4
4
|
* Context passed to `onActivate` / `onDeactivate` lifecycle hooks on an agent.
|
|
5
5
|
*
|
|
@@ -72,6 +72,28 @@ export type ToolHandlersInput = ChatToolHandlers | ((ctx: SystemPromptContext) =
|
|
|
72
72
|
* @beta
|
|
73
73
|
*/
|
|
74
74
|
export type ProviderInput = string | ((ctx: SystemPromptContext) => string | Promise<string>);
|
|
75
|
+
/**
|
|
76
|
+
* Sampling temperature for an agent, normalized to `0`–`1` (`0` = deterministic,
|
|
77
|
+
* `1` = the most random the active provider allows). Either a static number
|
|
78
|
+
* (resolved once) or a function resolved each tool-loop iteration — pick the
|
|
79
|
+
* function form to vary it by current state (e.g. a lower temperature for a
|
|
80
|
+
* precise extraction step, higher for brainstorming). Each transport translates
|
|
81
|
+
* the normalized value into its own native range. Omit to use the
|
|
82
|
+
* provider/model default. See `ChatRequestOptions.temperature`.
|
|
83
|
+
*
|
|
84
|
+
* @beta
|
|
85
|
+
*/
|
|
86
|
+
export type TemperatureInput = number | ((ctx: SystemPromptContext) => number | Promise<number>);
|
|
87
|
+
/**
|
|
88
|
+
* Tool-call mode for an agent. Either a static `ChatToolChoice` (resolved
|
|
89
|
+
* once) or a function resolved each tool-loop iteration — pick the function form
|
|
90
|
+
* to vary it by current state (e.g. force a classifier tool in an intake step,
|
|
91
|
+
* then `'auto'` everywhere multi-step work happens). Omit to use the default
|
|
92
|
+
* (`'auto'`, except sub-agent turns which force `'required'`).
|
|
93
|
+
*
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
export type ToolChoiceInput = ChatToolChoice | ((ctx: SystemPromptContext) => ChatToolChoice | Promise<ChatToolChoice>);
|
|
75
97
|
/**
|
|
76
98
|
* Opts an agent in to manual selection from the assistant's agent picker.
|
|
77
99
|
*
|
|
@@ -152,6 +174,27 @@ interface BaseAgentConfig {
|
|
|
152
174
|
* @beta
|
|
153
175
|
*/
|
|
154
176
|
provider?: ProviderInput;
|
|
177
|
+
/**
|
|
178
|
+
* Sampling temperature for this agent, normalized to `0`–`1`. Either a static
|
|
179
|
+
* number or a function resolved each tool-loop iteration — pick the function
|
|
180
|
+
* form to vary it by current state. Omit to use the provider/model default.
|
|
181
|
+
* Resolved and applied the same way as {@link BaseAgentConfig.provider}.
|
|
182
|
+
* See {@link TemperatureInput}.
|
|
183
|
+
*
|
|
184
|
+
* @beta
|
|
185
|
+
*/
|
|
186
|
+
temperature?: TemperatureInput;
|
|
187
|
+
/**
|
|
188
|
+
* Tool-call mode for this agent — whether the model may, must, or must not
|
|
189
|
+
* call a tool this turn (and optionally which one). Either a static value or
|
|
190
|
+
* a function resolved each tool-loop iteration — pick the function form to
|
|
191
|
+
* vary it by current state (e.g. force a single tool at a known juncture).
|
|
192
|
+
* Omit to use the default (`'auto'`, except sub-agent turns which force
|
|
193
|
+
* `'required'`). See {@link ToolChoiceInput}.
|
|
194
|
+
*
|
|
195
|
+
* @beta
|
|
196
|
+
*/
|
|
197
|
+
toolChoice?: ToolChoiceInput;
|
|
155
198
|
/**
|
|
156
199
|
* Optional primer history prepended to every call (not visible to the user).
|
|
157
200
|
* Used to establish agent identity and behavioural rules.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,4BAA4B,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,WAAW,EACX,cAAc,EACd,kBAAk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AClE;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,qBAAqB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB;;;;;;;;;;;OAWG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;IACf,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAErE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatMessage, ChatToolDefinition, ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
1
|
+
import type { ChatMessage, ChatToolChoice, ChatToolDefinition, ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
2
2
|
import type { AgentConfig, AgentLifecycleContext, ChatInputDuringExecutionMode, ManualSelectionConfig, SystemPromptContext } from './config';
|
|
3
3
|
/**
|
|
4
4
|
* Context passed to per-turn resolvers on a stateful agent — the standard
|
|
@@ -108,6 +108,21 @@ export interface StatefulAgentInit<S> {
|
|
|
108
108
|
* Omit to use the registry's default provider. Unknown names hard-error.
|
|
109
109
|
*/
|
|
110
110
|
provider?: string | ((ctx: StatefulAgentContext<S>) => string | Promise<string>);
|
|
111
|
+
/**
|
|
112
|
+
* Sampling temperature, normalized to `0`–`1`. Either a static number or a
|
|
113
|
+
* function resolved each tool-loop iteration with the current `state` — pick
|
|
114
|
+
* the function form to vary it per machine state (e.g. low for a precise
|
|
115
|
+
* extraction step, higher for free-form drafting). Omit for the default.
|
|
116
|
+
*/
|
|
117
|
+
temperature?: number | ((ctx: StatefulAgentContext<S>) => number | Promise<number>);
|
|
118
|
+
/**
|
|
119
|
+
* Tool-call mode. Either a static `ChatToolChoice` or a function
|
|
120
|
+
* resolved each tool-loop iteration with the current `state` — pick the
|
|
121
|
+
* function form to force a specific tool in one state (e.g. a classifier in
|
|
122
|
+
* intake) and leave `'auto'` in states where multi-step work happens. Omit
|
|
123
|
+
* for the default.
|
|
124
|
+
*/
|
|
125
|
+
toolChoice?: ChatToolChoice | ((ctx: StatefulAgentContext<S>) => ChatToolChoice | Promise<ChatToolChoice>);
|
|
111
126
|
/**
|
|
112
127
|
* Optional getter for the debug-log snapshot. Defaults to auto-snapshotting
|
|
113
128
|
* any property on `state` that looks like a foundation-state-machine
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-stateful-agent.d.ts","sourceRoot":"","sources":["../../../src/config/define-stateful-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"define-stateful-agent.d.ts","sourceRoot":"","sources":["../../../src/config/define-stateful-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,EAErB,mBAAmB,EAMpB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,mBAAmB,GAAG;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEzE;;;;;;;;;GASG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AC,gBAAgB,CAAC,CAAC;IAE1E;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjF;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpF;;;;;;OAMG;IACH,UAAU,CAAC,EACP,cAAc,GACd,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAEjF;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;CAC1C;AAsCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,WAAW,CAoK9E"}
|
package/dist/dts/main/main.d.ts
CHANGED
|
@@ -373,6 +373,8 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
373
373
|
timestamp: string;
|
|
374
374
|
agentName?: string;
|
|
375
375
|
toolNames: string[];
|
|
376
|
+
temperature?: number;
|
|
377
|
+
toolChoice?: import("@genesislcap/foundation-ai").ChatToolChoice;
|
|
376
378
|
agentLabel?: string;
|
|
377
379
|
agentSnapshot?: unknown;
|
|
378
380
|
kind: "turn";
|
|
@@ -390,6 +392,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
390
392
|
inputTokens?: number;
|
|
391
393
|
outputTokens?: number;
|
|
392
394
|
cost?: number;
|
|
395
|
+
responseMeta?: import("@genesislcap/foundation-ai").ChatResponseMeta;
|
|
393
396
|
kind: "message";
|
|
394
397
|
} | {
|
|
395
398
|
index: number;
|
|
@@ -415,6 +418,8 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
415
418
|
displayName?: import("../config/config").SystemPromptInput;
|
|
416
419
|
systemPrompt?: import("../config/config").SystemPromptInput;
|
|
417
420
|
provider?: import("../config/config").ProviderInput;
|
|
421
|
+
temperature?: import("../config/config").TemperatureInput;
|
|
422
|
+
toolChoice?: import("../config/config").ToolChoiceInput;
|
|
418
423
|
primerHistory?: ChatMessage[];
|
|
419
424
|
subAgents?: AgentConfig[];
|
|
420
425
|
chatInputDuringExecution?: ChatInputDuringExecutionMode;
|
|
@@ -431,6 +436,8 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
431
436
|
displayName?: import("../config/config").SystemPromptInput;
|
|
432
437
|
systemPrompt?: import("../config/config").SystemPromptInput;
|
|
433
438
|
provider?: import("../config/config").ProviderInput;
|
|
439
|
+
temperature?: import("../config/config").TemperatureInput;
|
|
440
|
+
toolChoice?: import("../config/config").ToolChoiceInput;
|
|
434
441
|
primerHistory?: ChatMessage[];
|
|
435
442
|
subAgents?: AgentConfig[];
|
|
436
443
|
chatInputDuringExecution?: ChatInputDuringExecutionMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main/main.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACd,UAAU,EACV,4BAA4B,EAC5B,WAAW,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAGL,cAAc,EAIf,MAAM,uBAAuB,CAAC;AAW/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAiBlC,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,gBA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this.debugSnapshotter = config.getDebugSnapshot;
|
|
257
257
|
this.subAgentsMap = new Map(((_c = config.subAgents) !== null && _c !== void 0 ? _c : []).map((s) => [s.name, s]));
|
|
258
258
|
this.activeProviderInput = config.provider;
|
|
259
|
+
this.activeTemperatureInput = config.temperature;
|
|
260
|
+
this.activeToolChoiceInput = config.toolChoice;
|
|
259
261
|
this.resolvedProviderCache.clear();
|
|
260
262
|
this.lastResolvedProviderName = undefined;
|
|
261
263
|
// Static validation: resolve the name now so unknown-provider and missing-
|
|
@@ -328,6 +330,20 @@ export class ChatDriver extends EventTarget {
|
|
|
328
330
|
return provider;
|
|
329
331
|
});
|
|
330
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Resolve a per-turn config input that is either a static value or a function
|
|
335
|
+
* of the turn context — the value-or-resolver shape shared by `provider`,
|
|
336
|
+
* `temperature`, and `toolChoice`. Returns undefined when the input is unset.
|
|
337
|
+
*/
|
|
338
|
+
resolveTurnInput(input, ctx) {
|
|
339
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
340
|
+
if (input === undefined)
|
|
341
|
+
return undefined;
|
|
342
|
+
return typeof input === 'function'
|
|
343
|
+
? input(ctx)
|
|
344
|
+
: input;
|
|
345
|
+
});
|
|
346
|
+
}
|
|
331
347
|
/**
|
|
332
348
|
* Returns the early-stop result set by `completeSubAgent`, if any.
|
|
333
349
|
* Called by a parent `ChatDriver` after running this instance as a sub-agent.
|
|
@@ -427,7 +443,7 @@ export class ChatDriver extends EventTarget {
|
|
|
427
443
|
* before each LLM call — that's the latest point where the prompt, tool
|
|
428
444
|
* surface, and agent state line up with what the model is about to see.
|
|
429
445
|
*/
|
|
430
|
-
recordTurnSnapshot(resolvedSystemPrompt) {
|
|
446
|
+
recordTurnSnapshot(resolvedSystemPrompt, temperature, toolChoice) {
|
|
431
447
|
let agentSnapshot;
|
|
432
448
|
if (this.debugSnapshotter) {
|
|
433
449
|
try {
|
|
@@ -449,6 +465,8 @@ export class ChatDriver extends EventTarget {
|
|
|
449
465
|
agentLabel: this.activeAgentLabel,
|
|
450
466
|
systemPrompt: resolvedSystemPrompt,
|
|
451
467
|
toolNames: this.toolDefinitions.map((t) => t.name),
|
|
468
|
+
temperature,
|
|
469
|
+
toolChoice,
|
|
452
470
|
agentSnapshot,
|
|
453
471
|
});
|
|
454
472
|
if (this.turnSnapshots.length > this.maxTurnSnapshots) {
|
|
@@ -1152,7 +1170,21 @@ export class ChatDriver extends EventTarget {
|
|
|
1152
1170
|
: emptyResponseAttempts > 0
|
|
1153
1171
|
? `${baseSystemPrompt !== null && baseSystemPrompt !== void 0 ? baseSystemPrompt : ''}\n\nIMPORTANT: You must respond to the user's message. Call the appropriate tool or provide a text response — do not return an empty response.`
|
|
1154
1172
|
: baseSystemPrompt;
|
|
1155
|
-
|
|
1173
|
+
// Resolve the per-turn temperature and tool-call mode the same way the
|
|
1174
|
+
// provider is resolved — static value or a function of the turn context
|
|
1175
|
+
// (which carries the live state for stateful agents). Resolved before the
|
|
1176
|
+
// snapshot so the debug log records the exact request config the model saw.
|
|
1177
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
1178
|
+
const [resolvedTemperature, resolvedToolChoice] = yield Promise.all([
|
|
1179
|
+
this.resolveTurnInput(this.activeTemperatureInput, promptCtx),
|
|
1180
|
+
this.resolveTurnInput(this.activeToolChoiceInput, promptCtx),
|
|
1181
|
+
]);
|
|
1182
|
+
// An agent/state-configured tool-call mode wins. Otherwise sub-agents must
|
|
1183
|
+
// finish by calling a tool (their completion tool) so the turn can't end
|
|
1184
|
+
// on a free-text answer; top-level agents stay 'auto'. (Transports no-op a
|
|
1185
|
+
// force when no tools are advertised.)
|
|
1186
|
+
const effectiveToolChoice = resolvedToolChoice !== null && resolvedToolChoice !== void 0 ? resolvedToolChoice : (this.isSubAgent ? 'required' : undefined);
|
|
1187
|
+
this.recordTurnSnapshot(systemPrompt, resolvedTemperature, effectiveToolChoice);
|
|
1156
1188
|
// Capture the pending user input, then clear the slots BEFORE the chat
|
|
1157
1189
|
// call. `sendMessage` already appended the user message to `this.history`,
|
|
1158
1190
|
// so on retries (empty / malformed) we must rely on history alone —
|
|
@@ -1171,11 +1203,10 @@ export class ChatDriver extends EventTarget {
|
|
|
1171
1203
|
// Per-turn signal: aborts on user cancel, and (via beginTurn's chain)
|
|
1172
1204
|
// on driver dispose. Cancels the in-flight request either way.
|
|
1173
1205
|
signal: this.turnController.signal,
|
|
1174
|
-
|
|
1175
|
-
//
|
|
1176
|
-
//
|
|
1177
|
-
|
|
1178
|
-
toolChoice: this.isSubAgent ? 'required' : undefined,
|
|
1206
|
+
toolChoice: effectiveToolChoice,
|
|
1207
|
+
// Agent/state-configured sampling temperature (normalized 0–1); each
|
|
1208
|
+
// transport translates it to its native range. Undefined → provider default.
|
|
1209
|
+
temperature: resolvedTemperature,
|
|
1179
1210
|
};
|
|
1180
1211
|
// Resolve the active provider for this turn. Static names were validated
|
|
1181
1212
|
// in `applyAgent`; function-form names are validated on first resolution
|
|
@@ -1266,22 +1297,12 @@ export class ChatDriver extends EventTarget {
|
|
|
1266
1297
|
emptyResponseAttempts += 1;
|
|
1267
1298
|
if (emptyResponseAttempts < MAX_EMPTY_RESPONSE_RETRIES) {
|
|
1268
1299
|
logger.warn(`ChatDriver: empty model response, retrying (${emptyResponseAttempts}/${MAX_EMPTY_RESPONSE_RETRIES})`);
|
|
1269
|
-
recordTurnRetry(this.sessionKey, 'empty-response', {
|
|
1270
|
-
agent: this.activeAgentName,
|
|
1271
|
-
provider: this.lastResolvedProviderName,
|
|
1272
|
-
attempt: emptyResponseAttempts,
|
|
1273
|
-
maxAttempts: MAX_EMPTY_RESPONSE_RETRIES,
|
|
1274
|
-
});
|
|
1300
|
+
recordTurnRetry(this.sessionKey, 'empty-response', Object.assign({ agent: this.activeAgentName, provider: this.lastResolvedProviderName, attempt: emptyResponseAttempts, maxAttempts: MAX_EMPTY_RESPONSE_RETRIES }, response.responseMeta));
|
|
1275
1301
|
iterations -= 1;
|
|
1276
1302
|
continue;
|
|
1277
1303
|
}
|
|
1278
1304
|
logger.error('ChatDriver: empty model response after all retries');
|
|
1279
|
-
recordTurnError(this.sessionKey, 'empty-response', {
|
|
1280
|
-
agent: this.activeAgentName,
|
|
1281
|
-
provider: this.lastResolvedProviderName,
|
|
1282
|
-
attempts: emptyResponseAttempts,
|
|
1283
|
-
isSubAgent: this.isSubAgent,
|
|
1284
|
-
});
|
|
1305
|
+
recordTurnError(this.sessionKey, 'empty-response', Object.assign({ agent: this.activeAgentName, provider: this.lastResolvedProviderName, attempts: emptyResponseAttempts, isSubAgent: this.isSubAgent }, response.responseMeta));
|
|
1285
1306
|
if (this.isSubAgent) {
|
|
1286
1307
|
this.failSubAgent('empty_response');
|
|
1287
1308
|
}
|
|
@@ -13,13 +13,16 @@ const scriptedProvider = (responses) => {
|
|
|
13
13
|
const queue = [...responses];
|
|
14
14
|
const advertisedPerCall = [];
|
|
15
15
|
const toolChoicePerCall = [];
|
|
16
|
+
const temperaturePerCall = [];
|
|
16
17
|
return {
|
|
17
18
|
advertisedPerCall,
|
|
18
19
|
toolChoicePerCall,
|
|
20
|
+
temperaturePerCall,
|
|
19
21
|
chat: (_history, _userMessage, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
22
|
var _a, _b;
|
|
21
23
|
advertisedPerCall.push(((_a = options === null || options === void 0 ? void 0 : options.tools) !== null && _a !== void 0 ? _a : []).map((t) => t.name));
|
|
22
24
|
toolChoicePerCall.push(options === null || options === void 0 ? void 0 : options.toolChoice);
|
|
25
|
+
temperaturePerCall.push(options === null || options === void 0 ? void 0 : options.temperature);
|
|
23
26
|
// Once the script is exhausted, end the turn with a plain text reply.
|
|
24
27
|
return (_b = queue.shift()) !== null && _b !== void 0 ? _b : { role: 'assistant', content: 'done' };
|
|
25
28
|
}),
|
|
@@ -514,3 +517,86 @@ subagent("forwards the sub-agent's turns onto the parent timeline, numbered unde
|
|
|
514
517
|
assert.ok(snaps.some((s) => s.turnIndex === '0'), 'the activating parent turn is present as a bare string counter');
|
|
515
518
|
}));
|
|
516
519
|
subagent.run();
|
|
520
|
+
// ---------------------------------------------------------------------------
|
|
521
|
+
// per-agent / per-state temperature & tool-call mode (GENC-1321)
|
|
522
|
+
//
|
|
523
|
+
// The driver resolves `temperature` and `toolChoice` the same way it resolves
|
|
524
|
+
// `provider`: a static value, or a function of the turn context (which carries
|
|
525
|
+
// the live state for stateful agents). These tests assert both forms reach the
|
|
526
|
+
// provider call, and that the per-turn (function) form re-resolves each call.
|
|
527
|
+
// ---------------------------------------------------------------------------
|
|
528
|
+
const settings = createLogicSuite('ChatDriver temperature & toolChoice');
|
|
529
|
+
settings('passes a static agent temperature and tool-call mode to the provider', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
530
|
+
const provider = scriptedProvider([]);
|
|
531
|
+
const driver = makeDriver(agent({ name: 'a', temperature: 0.3, toolChoice: 'none' }), provider);
|
|
532
|
+
yield driver.sendMessage('hi');
|
|
533
|
+
assert.is(provider.temperaturePerCall[0], 0.3);
|
|
534
|
+
assert.equal(provider.toolChoicePerCall[0], 'none');
|
|
535
|
+
// ...and surfaced in the per-turn debug snapshot (the effective values sent).
|
|
536
|
+
const snap = driver.getTurnSnapshots()[0];
|
|
537
|
+
assert.is(snap.temperature, 0.3);
|
|
538
|
+
assert.equal(snap.toolChoice, 'none');
|
|
539
|
+
}));
|
|
540
|
+
settings('re-resolves the function form per turn (carrying turn context)', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
541
|
+
const provider = scriptedProvider([callsTool('tool_a', 't1')]);
|
|
542
|
+
const config = agent({
|
|
543
|
+
name: 'b',
|
|
544
|
+
toolDefinitions: [def('tool_a')],
|
|
545
|
+
toolHandlers: { tool_a: () => __awaiter(void 0, void 0, void 0, function* () { return 'ok'; }) },
|
|
546
|
+
// turnIndex: 0 on the first LLM call, > 0 on subsequent tool-loop iterations.
|
|
547
|
+
temperature: (ctx) => (ctx.turnIndex === 0 ? 0.1 : 0.9),
|
|
548
|
+
toolChoice: (ctx) => (ctx.turnIndex === 0 ? { tool: 'tool_a' } : 'auto'),
|
|
549
|
+
});
|
|
550
|
+
yield makeDriver(config, provider).sendMessage('go');
|
|
551
|
+
// First call forces the named tool at a low temperature...
|
|
552
|
+
assert.is(provider.temperaturePerCall[0], 0.1);
|
|
553
|
+
assert.equal(provider.toolChoicePerCall[0], { tool: 'tool_a' });
|
|
554
|
+
// ...the follow-up call (after the tool result) sees the other branch.
|
|
555
|
+
assert.is(provider.temperaturePerCall[1], 0.9);
|
|
556
|
+
assert.equal(provider.toolChoicePerCall[1], 'auto');
|
|
557
|
+
}));
|
|
558
|
+
settings('leaves temperature and toolChoice unset when the agent does not configure them', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
559
|
+
const provider = scriptedProvider([]);
|
|
560
|
+
yield makeDriver(agent({ name: 'c' }), provider).sendMessage('hi');
|
|
561
|
+
assert.is(provider.temperaturePerCall[0], undefined);
|
|
562
|
+
assert.is(provider.toolChoicePerCall[0], undefined);
|
|
563
|
+
}));
|
|
564
|
+
settings.run();
|
|
565
|
+
// ---------------------------------------------------------------------------
|
|
566
|
+
// empty-response diagnostics (GENC-1321)
|
|
567
|
+
//
|
|
568
|
+
// The transport surfaces a provider diagnostic (Gemini: finishReason,
|
|
569
|
+
// thoughtsTokens, parts, blockReason) on the message; the driver must fold it
|
|
570
|
+
// into the empty-response meta events so the debug-log timeline shows *why* a
|
|
571
|
+
// turn came back blank — not just that it did.
|
|
572
|
+
// ---------------------------------------------------------------------------
|
|
573
|
+
const emptyDiag = createLogicSuite('ChatDriver empty-response diagnostics');
|
|
574
|
+
emptyDiag('folds the provider responseMeta into the empty-response meta events', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
575
|
+
var _a, _b, _c, _d;
|
|
576
|
+
clearMetaEventRegistry();
|
|
577
|
+
const provider = {
|
|
578
|
+
chat: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
579
|
+
return ({
|
|
580
|
+
role: 'assistant',
|
|
581
|
+
content: '',
|
|
582
|
+
responseMeta: {
|
|
583
|
+
finishReason: 'STOP',
|
|
584
|
+
thoughtsTokens: 999,
|
|
585
|
+
parts: { functionCall: 0, thought: 0, text: 0 },
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
}),
|
|
589
|
+
};
|
|
590
|
+
const sessionKey = 'empty-diag';
|
|
591
|
+
yield makeDriver(agent({ name: 'Static' }), provider, sessionKey).sendMessage('go');
|
|
592
|
+
// Both the in-turn retries and the final bail carry the diagnostic.
|
|
593
|
+
const retry = getMetaEvents(sessionKey).find((e) => { var _a; return e.type === 'turn.retry' && ((_a = e.detail) === null || _a === void 0 ? void 0 : _a.reason) === 'empty-response'; });
|
|
594
|
+
assert.ok(retry, 'an empty-response turn.retry should be recorded');
|
|
595
|
+
assert.is((_a = retry.detail) === null || _a === void 0 ? void 0 : _a.finishReason, 'STOP');
|
|
596
|
+
assert.is((_b = retry.detail) === null || _b === void 0 ? void 0 : _b.thoughtsTokens, 999);
|
|
597
|
+
const err = getMetaEvents(sessionKey).find((e) => { var _a; return e.type === 'turn.error' && ((_a = e.detail) === null || _a === void 0 ? void 0 : _a.reason) === 'empty-response'; });
|
|
598
|
+
assert.ok(err, 'an empty-response turn.error should be recorded after retries');
|
|
599
|
+
assert.is((_c = err.detail) === null || _c === void 0 ? void 0 : _c.finishReason, 'STOP');
|
|
600
|
+
assert.is((_d = err.detail) === null || _d === void 0 ? void 0 : _d.thoughtsTokens, 999);
|
|
601
|
+
}));
|
|
602
|
+
emptyDiag.run();
|
|
@@ -118,6 +118,24 @@ export function defineStatefulAgent(opts) {
|
|
|
118
118
|
return opts.provider(Object.assign(Object.assign({}, ctx), { state }));
|
|
119
119
|
})
|
|
120
120
|
: opts.provider;
|
|
121
|
+
// `temperature` and `toolChoice` thread `state` in exactly like `provider`;
|
|
122
|
+
// static values pass through unchanged.
|
|
123
|
+
const wrappedTemperature = typeof opts.temperature === 'function'
|
|
124
|
+
? (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
if (!state) {
|
|
126
|
+
throw new Error(`Stateful agent "${opts.name}" temperature called before init`);
|
|
127
|
+
}
|
|
128
|
+
return opts.temperature(Object.assign(Object.assign({}, ctx), { state }));
|
|
129
|
+
})
|
|
130
|
+
: opts.temperature;
|
|
131
|
+
const wrappedToolChoice = typeof opts.toolChoice === 'function'
|
|
132
|
+
? (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
if (!state) {
|
|
134
|
+
throw new Error(`Stateful agent "${opts.name}" toolChoice called before init`);
|
|
135
|
+
}
|
|
136
|
+
return opts.toolChoice(Object.assign(Object.assign({}, ctx), { state }));
|
|
137
|
+
})
|
|
138
|
+
: opts.toolChoice;
|
|
121
139
|
const base = {
|
|
122
140
|
name: opts.name,
|
|
123
141
|
displayName: wrappedDisplayName,
|
|
@@ -128,6 +146,8 @@ export function defineStatefulAgent(opts) {
|
|
|
128
146
|
toolDefinitions: wrappedTools,
|
|
129
147
|
toolHandlers: wrappedHandlers,
|
|
130
148
|
provider: wrappedProvider,
|
|
149
|
+
temperature: wrappedTemperature,
|
|
150
|
+
toolChoice: wrappedToolChoice,
|
|
131
151
|
onActivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
132
152
|
state = yield opts.init(ctx);
|
|
133
153
|
// Sample once with the init state to fail loud on fold misuse at the
|
package/dist/esm/main/main.js
CHANGED
|
@@ -70,13 +70,15 @@ avoidTreeShaking(AiChatMarkdown, AiChatInteractionWrapper, AiHaloOverlay, AiChat
|
|
|
70
70
|
* - `toolHandlers` (functions),
|
|
71
71
|
* - `onActivate` / `onDeactivate` (lifecycle hooks, functions),
|
|
72
72
|
* - `getDebugSnapshot` (function),
|
|
73
|
-
* - function-form `systemPrompt` / `toolDefinitions` / `displayName` / `provider`
|
|
73
|
+
* - function-form `systemPrompt` / `toolDefinitions` / `displayName` / `provider` /
|
|
74
|
+
* `temperature` / `toolChoice`
|
|
74
75
|
* (downgraded to `undefined` in the snapshot — the live config on the driver
|
|
75
76
|
* is still the source of truth; the slice only stores a serializable projection).
|
|
77
|
+
* Static forms (string / number / plain-object `toolChoice`) pass through.
|
|
76
78
|
*/
|
|
77
79
|
function stripHandlers(agent) {
|
|
78
|
-
const { toolHandlers: _h, onActivate: _on, onDeactivate: _off, getDebugSnapshot: _g, subAgents, systemPrompt, toolDefinitions, displayName, provider } = agent, rest = __rest(agent, ["toolHandlers", "onActivate", "onDeactivate", "getDebugSnapshot", "subAgents", "systemPrompt", "toolDefinitions", "displayName", "provider"]);
|
|
79
|
-
const stripped = Object.assign(Object.assign({}, rest), { systemPrompt: typeof systemPrompt === 'function' ? undefined : systemPrompt, toolDefinitions: typeof toolDefinitions === 'function' ? undefined : toolDefinitions, displayName: typeof displayName === 'function' ? undefined : displayName, provider: typeof provider === 'function' ? undefined : provider });
|
|
80
|
+
const { toolHandlers: _h, onActivate: _on, onDeactivate: _off, getDebugSnapshot: _g, subAgents, systemPrompt, toolDefinitions, displayName, provider, temperature, toolChoice } = agent, rest = __rest(agent, ["toolHandlers", "onActivate", "onDeactivate", "getDebugSnapshot", "subAgents", "systemPrompt", "toolDefinitions", "displayName", "provider", "temperature", "toolChoice"]);
|
|
81
|
+
const stripped = Object.assign(Object.assign({}, rest), { systemPrompt: typeof systemPrompt === 'function' ? undefined : systemPrompt, toolDefinitions: typeof toolDefinitions === 'function' ? undefined : toolDefinitions, displayName: typeof displayName === 'function' ? undefined : displayName, provider: typeof provider === 'function' ? undefined : provider, temperature: typeof temperature === 'function' ? undefined : temperature, toolChoice: typeof toolChoice === 'function' ? undefined : toolChoice });
|
|
80
82
|
return (subAgents === null || subAgents === void 0 ? void 0 : subAgents.length)
|
|
81
83
|
? Object.assign(Object.assign({}, stripped), { subAgents: subAgents.map(stripHandlers) }) : stripped;
|
|
82
84
|
}
|
|
@@ -140,7 +140,7 @@ export const DEBUG_LOG_README = [
|
|
|
140
140
|
"kind:'turn'.`agentSnapshot` — the active agent's own view of its internal state, captured at that turn. An agent opts into this by exposing a `getDebugSnapshot()` that returns JSON-serializable per-state info; stateful/flow agents wire it automatically, so you can watch a flow advance turn-by-turn (e.g. current step, cursor, collected fields, pending changes). Absent for agents that don't expose one.",
|
|
141
141
|
"kind:'event' — a meta/lifecycle event. `type` names it (see below); `detail` carries structured data. `detail.placement` is the emitting UI instance: 'bubble' (collapsed), 'panel' (popped-out), or 'standalone'.",
|
|
142
142
|
"Each 'event' also has an `importance`: 'high' (failures/limits — turn.error, tool.failed, file.read-failed, suggestions.failed, context.threshold-crossed), 'normal' (session flow — connects, turns, retries, handoffs, agent/provider changes, interactions), or 'low' (skippable UI/bookkeeping noise — panel.toggled, attachment.added, driver.wired/unwired, context.updated). To skim, ignore importance:'low'; to triage a failure, filter to importance:'high' then read the nearby messages and turns. A 'high' turn.error is often preceded by one or more 'normal' turn.retry events for the same reason — read them together to see how many attempts were made before bailing. 'message' and 'turn' entries carry no importance — they are the substance, always read them.",
|
|
143
|
-
'Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle↔loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry — detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage), turn.error (a turn failed or hit a guardrail — detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations, plus reason-specific diagnostics: attempts, finishMessage, unknownTools (split into staleTools — real earlier this activation but retired by the current state or hidden behind an open exclusive fold — and hallucinatedTools — never advertised) + availableTools, iterations + limit, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched — detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; the recurring lead-up to an unknown-tool-limit turn.error), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), provider.selected (model/provider for the upcoming turns), interaction.requested/resolved (blocking user widgets — explain quiet gaps), context.updated/threshold-crossed (token + cost), panel.toggled, attachment.added, file.read-failed, suggestions.failed.',
|
|
143
|
+
'Event types: assistant.connected/disconnected (mount + placement + whether the session was created or restored), assistant.popout/popin (window placement), driver.created/wired/unwired (which driver is live and why it stops/starts responding across a popout), state.changed (idle↔loading), turn.start/turn.end (turn boundary; turn.end carries durationMs), turn.retry (a recoverable in-turn retry — detail.reason plus attempt/maxAttempts; for malformed calls also finishMessage; for empty responses also the provider finishReason + thoughtsTokens + parts breakdown), turn.error (a turn failed or hit a guardrail — detail.reason is one of exception/malformed-function-call/empty-response/unknown-tool-limit/max-iterations, plus reason-specific diagnostics: attempts (for empty-response also finishReason + thoughtsTokens + a parts breakdown, distinguishing a thinking-only STOP from a truly empty turn), finishMessage, unknownTools (split into staleTools — real earlier this activation but retired by the current state or hidden behind an open exclusive fold — and hallucinatedTools — never advertised) + availableTools, iterations + limit, or name + message for exceptions), tool.failed (a tool threw), tool.unresolved (the model called a tool that could not be dispatched — detail.kind is folded/fold-hidden/stale/unknown, plus tool + agent and, for the counted kinds, the consecutive streak; the recurring lead-up to an unknown-tool-limit turn.error), agent.handoff (routing; from=null is the initial activation), agent.pinned/unpinned (forced routing), provider.selected (model/provider for the upcoming turns), interaction.requested/resolved (blocking user widgets — explain quiet gaps), context.updated/threshold-crossed (token + cost), panel.toggled, attachment.added, file.read-failed, suggestions.failed.',
|
|
144
144
|
"`meta` holds context captured at export time: agentSummary (full agent configs), context (active model, token usage, session cost), activeDebugSnapshot (the active agent's `getDebugSnapshot()` taken fresh at export — reflects state NOW, which may have advanced beyond the last turn's agentSnapshot), debug (optional host-supplied debug state), host, and the export timestamp.",
|
|
145
145
|
'To debug a failure: find the last turn.error or tool.failed, then read upward for the user message, the turn(s), and the agent/provider/state events that led into it.',
|
|
146
146
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/ai-assistant",
|
|
3
3
|
"description": "Genesis AI Assistant micro-frontend",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.455.1",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/ai-assistant.d.ts",
|
|
@@ -64,24 +64,24 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@genesislcap/foundation-testing": "14.
|
|
68
|
-
"@genesislcap/genx": "14.
|
|
69
|
-
"@genesislcap/rollup-builder": "14.
|
|
70
|
-
"@genesislcap/ts-builder": "14.
|
|
71
|
-
"@genesislcap/uvu-playwright-builder": "14.
|
|
72
|
-
"@genesislcap/vite-builder": "14.
|
|
73
|
-
"@genesislcap/webpack-builder": "14.
|
|
67
|
+
"@genesislcap/foundation-testing": "14.455.1",
|
|
68
|
+
"@genesislcap/genx": "14.455.1",
|
|
69
|
+
"@genesislcap/rollup-builder": "14.455.1",
|
|
70
|
+
"@genesislcap/ts-builder": "14.455.1",
|
|
71
|
+
"@genesislcap/uvu-playwright-builder": "14.455.1",
|
|
72
|
+
"@genesislcap/vite-builder": "14.455.1",
|
|
73
|
+
"@genesislcap/webpack-builder": "14.455.1",
|
|
74
74
|
"@types/dompurify": "^3.0.5",
|
|
75
75
|
"@types/marked": "^5.0.2"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@genesislcap/foundation-ai": "14.
|
|
79
|
-
"@genesislcap/foundation-logger": "14.
|
|
80
|
-
"@genesislcap/foundation-redux": "14.
|
|
81
|
-
"@genesislcap/foundation-ui": "14.
|
|
82
|
-
"@genesislcap/foundation-utils": "14.
|
|
83
|
-
"@genesislcap/rapid-design-system": "14.
|
|
84
|
-
"@genesislcap/web-core": "14.
|
|
78
|
+
"@genesislcap/foundation-ai": "14.455.1",
|
|
79
|
+
"@genesislcap/foundation-logger": "14.455.1",
|
|
80
|
+
"@genesislcap/foundation-redux": "14.455.1",
|
|
81
|
+
"@genesislcap/foundation-ui": "14.455.1",
|
|
82
|
+
"@genesislcap/foundation-utils": "14.455.1",
|
|
83
|
+
"@genesislcap/rapid-design-system": "14.455.1",
|
|
84
|
+
"@genesislcap/web-core": "14.455.1",
|
|
85
85
|
"dompurify": "^3.3.1",
|
|
86
86
|
"marked": "^17.0.3"
|
|
87
87
|
},
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "241f307737ad1b5c690bb4c947e61b2697159196"
|
|
97
97
|
}
|