@linnlabs/linnkit 0.45.0 → 0.47.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.
- package/CHANGELOG.md +60 -0
- package/dist/cli.cjs +65 -243
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +65 -243
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +7 -6
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.js +7 -6
- package/dist/context-manager.js.map +1 -1
- package/dist/index.cjs +75 -253
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +75 -253
- package/dist/index.js.map +1 -1
- package/dist/ports/llm-call.d.cts +2 -16
- package/dist/ports/llm-call.d.ts +2 -16
- package/dist/quickstart.cjs +65 -243
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +65 -243
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/graph-engine/executor.d.cts +0 -2
- package/dist/runtime-kernel/graph-engine/executor.d.ts +0 -2
- package/dist/runtime-kernel/graph-engine/types.d.cts +1 -4
- package/dist/runtime-kernel/graph-engine/types.d.ts +1 -4
- package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.cts +1 -2
- package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.ts +1 -2
- package/dist/runtime-kernel/llm/modelCatalog.d.cts +2 -3
- package/dist/runtime-kernel/llm/modelCatalog.d.ts +2 -3
- package/dist/runtime-kernel.cjs +75 -253
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +75 -253
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +83 -261
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +83 -261
- package/dist/testkit.js.map +1 -1
- package/docs/integration/agent-registration-guide.md +1 -1
- package/docs/integration/context-engineering.md +5 -5
- package/docs/integration/llm-provider.md +1 -1
- package/docs/integration/tool-development-guide.md +4 -2
- package/package.json +2 -1
package/dist/quickstart.js
CHANGED
|
@@ -2332,18 +2332,6 @@ var ErrorClassifier = class {
|
|
|
2332
2332
|
});
|
|
2333
2333
|
}
|
|
2334
2334
|
}
|
|
2335
|
-
const quotaPatterns = ["\u5DF2\u8FBE\u4E0A\u9650", "\u514D\u8D39\u671F\u5DF2\u7ED3\u675F"];
|
|
2336
|
-
for (const pattern of quotaPatterns) {
|
|
2337
|
-
if (errorMessage.includes(pattern)) {
|
|
2338
|
-
logClassification(context, "\u68C0\u6D4B\u5230\u4E91\u7AEF\u989D\u5EA6\u9650\u5236\uFF0C\u4E0D\u91CD\u8BD5", { matchedPattern: pattern });
|
|
2339
|
-
return createClassification("non_retryable" /* NON_RETRYABLE */, `\u4E91\u7AEF\u989D\u5EA6\u9650\u5236: ${pattern}`, null, {
|
|
2340
|
-
errorCode: ENGINE_ERROR_CODES.LLM_PROVIDER_DOWN,
|
|
2341
|
-
recoverable: false,
|
|
2342
|
-
hint: "check_billing_or_provider_status",
|
|
2343
|
-
metadata: { matchedPattern: pattern }
|
|
2344
|
-
});
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
2335
|
const authPatterns = [
|
|
2348
2336
|
{ pattern: "unauthorized", code: "401" },
|
|
2349
2337
|
{ pattern: "forbidden", code: "403" },
|
|
@@ -2598,17 +2586,6 @@ var ErrorClassifier = class {
|
|
|
2598
2586
|
}
|
|
2599
2587
|
return Math.max(baseDelay, classification.suggestedDelay ?? 0);
|
|
2600
2588
|
}
|
|
2601
|
-
static isCloudQuotaError(error) {
|
|
2602
|
-
const msg = (error.message || "").toLowerCase();
|
|
2603
|
-
const patterns = [
|
|
2604
|
-
"\u989D\u5EA6\u4E0A\u9650",
|
|
2605
|
-
"\u5DF2\u8FBE\u4E0A\u9650",
|
|
2606
|
-
"\u514D\u8D39\u671F\u5DF2\u7ED3\u675F",
|
|
2607
|
-
"\u8BE5\u6A21\u578B\u6682\u4E0D\u53EF\u7528",
|
|
2608
|
-
"cloud_quota_exhausted"
|
|
2609
|
-
];
|
|
2610
|
-
return patterns.some((pattern) => msg.includes(pattern));
|
|
2611
|
-
}
|
|
2612
2589
|
};
|
|
2613
2590
|
|
|
2614
2591
|
// src/shared/engineErrorEvent.ts
|
|
@@ -4092,8 +4069,8 @@ var TokenCalculator = class {
|
|
|
4092
4069
|
return;
|
|
4093
4070
|
}
|
|
4094
4071
|
this.failedEncodingWarnings.add(requestedEncoding);
|
|
4095
|
-
const
|
|
4096
|
-
|
|
4072
|
+
const logger18 = new Logger("TokenCalculator");
|
|
4073
|
+
logger18.warn("tiktoken encoding unavailable, falling back to avgCharsPerToken estimator", {
|
|
4097
4074
|
requestedEncoding,
|
|
4098
4075
|
error
|
|
4099
4076
|
});
|
|
@@ -4185,49 +4162,6 @@ var llmTelemetryMiddleware = async (ctx, stage, next) => {
|
|
|
4185
4162
|
});
|
|
4186
4163
|
};
|
|
4187
4164
|
|
|
4188
|
-
// src/runtime-kernel/graph-engine/functions/runModelLock.ts
|
|
4189
|
-
function readNonEmptyString4(value) {
|
|
4190
|
-
if (typeof value !== "string") return void 0;
|
|
4191
|
-
const trimmed = value.trim();
|
|
4192
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
4193
|
-
}
|
|
4194
|
-
function decideRunModelLockPatch(params) {
|
|
4195
|
-
if (params.stageId !== "execute_llm") {
|
|
4196
|
-
return { shouldLog: false };
|
|
4197
|
-
}
|
|
4198
|
-
const normalized = readNonEmptyString4(params.appliedFallbackModelId);
|
|
4199
|
-
if (!normalized) {
|
|
4200
|
-
return { shouldLog: false };
|
|
4201
|
-
}
|
|
4202
|
-
if (readNonEmptyString4(params.currentRunLockedModelId) === normalized) {
|
|
4203
|
-
return { shouldLog: false };
|
|
4204
|
-
}
|
|
4205
|
-
return {
|
|
4206
|
-
executorLocalPatch: { runLockedModelId: normalized },
|
|
4207
|
-
shouldLog: true
|
|
4208
|
-
};
|
|
4209
|
-
}
|
|
4210
|
-
|
|
4211
|
-
// src/runtime-kernel/graph-engine/tick-pipeline/middlewares/runModelLockMiddleware.ts
|
|
4212
|
-
var logger4 = new Logger("GraphAgentExecutor");
|
|
4213
|
-
var runModelLockMiddleware = async (ctx, stage, next) => {
|
|
4214
|
-
await next();
|
|
4215
|
-
const decision = decideRunModelLockPatch({
|
|
4216
|
-
stageId: stage.id,
|
|
4217
|
-
appliedFallbackModelId: ctx.cloudQuotaFallbackAppliedModelId,
|
|
4218
|
-
currentRunLockedModelId: ctx.executorLocalPatch?.runLockedModelId ?? ctx.executorLocal?.runLockedModelId
|
|
4219
|
-
});
|
|
4220
|
-
if (!decision.executorLocalPatch) {
|
|
4221
|
-
return;
|
|
4222
|
-
}
|
|
4223
|
-
if (decision.shouldLog) {
|
|
4224
|
-
logger4.warn(`\u68C0\u6D4B\u5230\u4E91\u7AEF\u989D\u5EA6\u964D\u7EA7\uFF0C\u5DF2\u9501\u5B9A\u672C run \u540E\u7EED\u6A21\u578B: ${ctx.modelId} -> ${decision.executorLocalPatch.runLockedModelId}`);
|
|
4225
|
-
}
|
|
4226
|
-
return {
|
|
4227
|
-
executorLocalPatch: decision.executorLocalPatch
|
|
4228
|
-
};
|
|
4229
|
-
};
|
|
4230
|
-
|
|
4231
4165
|
// src/runtime-kernel/graph-engine/tick-pipeline/runTickPipeline.ts
|
|
4232
4166
|
var tickPipelineContextKeys = [
|
|
4233
4167
|
"input",
|
|
@@ -4263,7 +4197,6 @@ var tickPipelineContextKeys = [
|
|
|
4263
4197
|
"decision",
|
|
4264
4198
|
"systemReminderHitRuleIds",
|
|
4265
4199
|
"contextTrace",
|
|
4266
|
-
"cloudQuotaFallbackAppliedModelId",
|
|
4267
4200
|
"modelFallbackAudit",
|
|
4268
4201
|
"telemetry",
|
|
4269
4202
|
"audit",
|
|
@@ -4602,7 +4535,7 @@ ${normalized}
|
|
|
4602
4535
|
}
|
|
4603
4536
|
|
|
4604
4537
|
// src/runtime-kernel/system-reminder/apply.ts
|
|
4605
|
-
var
|
|
4538
|
+
var logger4 = new Logger("SystemReminder");
|
|
4606
4539
|
var readString2 = (v) => {
|
|
4607
4540
|
if (typeof v !== "string") return void 0;
|
|
4608
4541
|
const s = v;
|
|
@@ -4665,7 +4598,7 @@ function applySystemReminders(params) {
|
|
|
4665
4598
|
} catch {
|
|
4666
4599
|
}
|
|
4667
4600
|
}
|
|
4668
|
-
|
|
4601
|
+
logger4.info("SystemReminder \u5DF2\u6CE8\u5165\u5230 LLM \u8F93\u5165\u672B\u5C3E", {
|
|
4669
4602
|
ruleIds: injectedRuleIds.length > 0 ? injectedRuleIds : Array.from(seenRuleIds),
|
|
4670
4603
|
promptKey: ctx.request.promptKey,
|
|
4671
4604
|
executorLocal: {
|
|
@@ -5157,18 +5090,14 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5157
5090
|
"turnId"
|
|
5158
5091
|
],
|
|
5159
5092
|
writes: [
|
|
5160
|
-
"cloudQuotaFallbackAppliedModelId",
|
|
5161
5093
|
"modelFallbackAudit",
|
|
5162
5094
|
"llmCallStartedAt",
|
|
5163
5095
|
"llmResp",
|
|
5164
5096
|
"llmCallDurationMs",
|
|
5165
|
-
"executorLocalPatch",
|
|
5166
5097
|
"contextUsage"
|
|
5167
5098
|
],
|
|
5168
5099
|
async run(ctx) {
|
|
5169
|
-
let cloudQuotaFallbackAppliedModelId;
|
|
5170
5100
|
let modelFallbackAudit;
|
|
5171
|
-
let lastSuccessfulLlmModelId;
|
|
5172
5101
|
let contextUsage;
|
|
5173
5102
|
const modelFallbackRejections = [];
|
|
5174
5103
|
const promptBudget = ctx.promptBudget;
|
|
@@ -5186,11 +5115,7 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5186
5115
|
streamEventHandler,
|
|
5187
5116
|
ctx.signal,
|
|
5188
5117
|
{
|
|
5189
|
-
|
|
5190
|
-
cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
|
|
5191
|
-
},
|
|
5192
|
-
onLlmAttemptSucceeded(activeModelId, attemptContextUsage) {
|
|
5193
|
-
lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
|
|
5118
|
+
onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
|
|
5194
5119
|
contextUsage = attemptContextUsage;
|
|
5195
5120
|
},
|
|
5196
5121
|
onModelFallbackApplied(info) {
|
|
@@ -5286,12 +5211,10 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5286
5211
|
});
|
|
5287
5212
|
}
|
|
5288
5213
|
return {
|
|
5289
|
-
cloudQuotaFallbackAppliedModelId,
|
|
5290
5214
|
modelFallbackAudit,
|
|
5291
5215
|
llmCallStartedAt,
|
|
5292
5216
|
llmResp,
|
|
5293
5217
|
llmCallDurationMs,
|
|
5294
|
-
executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
|
|
5295
5218
|
contextUsage
|
|
5296
5219
|
};
|
|
5297
5220
|
}
|
|
@@ -6208,18 +6131,16 @@ function createPrepareCallStage(dependencies) {
|
|
|
6208
6131
|
"toolDefinitionTokens"
|
|
6209
6132
|
],
|
|
6210
6133
|
async run(ctx) {
|
|
6211
|
-
const
|
|
6212
|
-
const requestedModelId = lockedRunModelId ?? ctx.request.model_id;
|
|
6134
|
+
const requestedModelId = ctx.request.model_id;
|
|
6213
6135
|
const modelId = dependencies.modelResolver.resolveModelId(requestedModelId);
|
|
6214
6136
|
await emitAuditEnvelope(ctx.audit, {
|
|
6215
6137
|
action: "model.select",
|
|
6216
6138
|
actor: { kind: "system" },
|
|
6217
6139
|
decision: {
|
|
6218
6140
|
outcome: "recorded",
|
|
6219
|
-
reason:
|
|
6141
|
+
reason: requestedModelId ? "request model id" : "default model resolver",
|
|
6220
6142
|
metadata: {
|
|
6221
6143
|
requestedModelId,
|
|
6222
|
-
lockedRunModelId,
|
|
6223
6144
|
selectedModelId: modelId
|
|
6224
6145
|
}
|
|
6225
6146
|
},
|
|
@@ -6266,10 +6187,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6266
6187
|
if (ctx.executorLocal?.lockRequestedModelId === true) {
|
|
6267
6188
|
llmOptions.allow_model_fallback = false;
|
|
6268
6189
|
}
|
|
6269
|
-
const isRunContinuation = ctx.executorLocal?.llmInvocationKind === "continuation";
|
|
6270
|
-
if (dependencies.cloudQuotaFallbackModelId && modelConfig?.billing_mode === "cloud" && modelId !== dependencies.cloudQuotaFallbackModelId && isRunContinuation && ctx.executorLocal?.lockRequestedModelId !== true) {
|
|
6271
|
-
llmOptions.cloud_quota_fallback_model_id = dependencies.cloudQuotaFallbackModelId;
|
|
6272
|
-
}
|
|
6273
6190
|
const effectiveEffort = resolveEffectiveEffort(
|
|
6274
6191
|
ctx.request.reasoning_effort,
|
|
6275
6192
|
modelConfig?.reasoning
|
|
@@ -6386,12 +6303,11 @@ function applyCalibration(rawLocalTotal, imageInputTokens, coefficient) {
|
|
|
6386
6303
|
}
|
|
6387
6304
|
|
|
6388
6305
|
// src/runtime-kernel/graph-engine/executor.ts
|
|
6389
|
-
var
|
|
6306
|
+
var logger5 = new Logger("GraphAgentExecutor");
|
|
6390
6307
|
var GraphAgentExecutor = class {
|
|
6391
6308
|
llmCaller;
|
|
6392
6309
|
toolRuntime;
|
|
6393
6310
|
contextBuilder;
|
|
6394
|
-
cloudQuotaFallbackModelId;
|
|
6395
6311
|
modelResolver;
|
|
6396
6312
|
modelCatalog;
|
|
6397
6313
|
telemetryPort;
|
|
@@ -6403,7 +6319,6 @@ var GraphAgentExecutor = class {
|
|
|
6403
6319
|
this.llmCaller = dependencies.llmCaller;
|
|
6404
6320
|
this.toolRuntime = dependencies.toolRuntime;
|
|
6405
6321
|
this.contextBuilder = dependencies.contextBuilder;
|
|
6406
|
-
this.cloudQuotaFallbackModelId = readNonEmptyString3(dependencies.cloudQuotaFallbackModelId);
|
|
6407
6322
|
this.modelCatalog = dependencies.modelCatalog ?? createEmptyModelCatalog();
|
|
6408
6323
|
this.modelResolver = dependencies.modelResolver ?? new ModelResolver({
|
|
6409
6324
|
modelCatalog: this.modelCatalog
|
|
@@ -6420,8 +6335,7 @@ var GraphAgentExecutor = class {
|
|
|
6420
6335
|
createPrepareCallStage({
|
|
6421
6336
|
modelResolver: this.modelResolver,
|
|
6422
6337
|
modelCatalog: this.modelCatalog,
|
|
6423
|
-
toolCatalog: this.toolRuntime
|
|
6424
|
-
cloudQuotaFallbackModelId: this.cloudQuotaFallbackModelId
|
|
6338
|
+
toolCatalog: this.toolRuntime
|
|
6425
6339
|
}),
|
|
6426
6340
|
createBuildContextStage({
|
|
6427
6341
|
contextBuilder: this.contextBuilder
|
|
@@ -6443,7 +6357,7 @@ var GraphAgentExecutor = class {
|
|
|
6443
6357
|
}),
|
|
6444
6358
|
createBuildDecisionStage()
|
|
6445
6359
|
];
|
|
6446
|
-
this.middlewares = [llmTelemetryMiddleware
|
|
6360
|
+
this.middlewares = [llmTelemetryMiddleware];
|
|
6447
6361
|
}
|
|
6448
6362
|
async tick(input, eventHandler) {
|
|
6449
6363
|
const ctx = {
|
|
@@ -6468,7 +6382,7 @@ var GraphAgentExecutor = class {
|
|
|
6468
6382
|
audit: this.auditPort,
|
|
6469
6383
|
tokenizer: this.tokenizer
|
|
6470
6384
|
};
|
|
6471
|
-
|
|
6385
|
+
logger5.info("[GraphAgentExecutor] tick \u8C03\u7528", {
|
|
6472
6386
|
stream: input.stream === true,
|
|
6473
6387
|
hasEventHandler: Boolean(eventHandler),
|
|
6474
6388
|
hasSummarizationCallbacks: Boolean(input.summarizationCallbacks)
|
|
@@ -7491,7 +7405,7 @@ var LlmNodeEventBridge = class {
|
|
|
7491
7405
|
};
|
|
7492
7406
|
|
|
7493
7407
|
// src/runtime-kernel/graph-engine/nodes/llmNode.ts
|
|
7494
|
-
var
|
|
7408
|
+
var logger6 = new Logger("LlmNode");
|
|
7495
7409
|
var LlmNode = class {
|
|
7496
7410
|
id = "llm";
|
|
7497
7411
|
reasoner;
|
|
@@ -7500,7 +7414,7 @@ var LlmNode = class {
|
|
|
7500
7414
|
}
|
|
7501
7415
|
async run(state) {
|
|
7502
7416
|
const local = state.local ?? {};
|
|
7503
|
-
|
|
7417
|
+
logger6.info("[LlmNode] \u5F00\u59CB\u6267\u884C LLM \u8282\u70B9", {
|
|
7504
7418
|
localKeys: Object.keys(local)
|
|
7505
7419
|
});
|
|
7506
7420
|
const graphLocal = readGraphAgentLocal(state.local);
|
|
@@ -7515,12 +7429,12 @@ var LlmNode = class {
|
|
|
7515
7429
|
signal,
|
|
7516
7430
|
history
|
|
7517
7431
|
} = graphLocal;
|
|
7518
|
-
|
|
7432
|
+
logger6.info("[LlmNode] \u5DF2\u52A0\u8F7D\u5386\u53F2\u4E8B\u4EF6", {
|
|
7519
7433
|
historyCount: history.length,
|
|
7520
7434
|
hasSummarizationCallbacks: Boolean(summarizationCallbacks)
|
|
7521
7435
|
});
|
|
7522
7436
|
if (!request) {
|
|
7523
|
-
|
|
7437
|
+
logger6.warn("Request object is missing, yielding.");
|
|
7524
7438
|
return { kind: "yield", events: [] };
|
|
7525
7439
|
}
|
|
7526
7440
|
const turnId = requireRuntimeIdentity(graphLocal.turnId, "turnId");
|
|
@@ -7613,12 +7527,12 @@ var LlmNode = class {
|
|
|
7613
7527
|
...nodeState.streamRuntimeEvents,
|
|
7614
7528
|
...contextUsageEvent ? [contextUsageEvent] : []
|
|
7615
7529
|
];
|
|
7616
|
-
|
|
7530
|
+
logger6.info("[LlmNode] \u5386\u53F2\u4E8B\u4EF6\u5DF2\u66F4\u65B0", {
|
|
7617
7531
|
previousCount: history.length,
|
|
7618
7532
|
nextCount: patch.history.length,
|
|
7619
7533
|
streamedEventCount: nodeState.streamRuntimeEvents.length
|
|
7620
7534
|
});
|
|
7621
|
-
|
|
7535
|
+
logger6.info("[LlmNode] \u6267\u884C\u5668\u51B3\u7B56\u5B8C\u6210", {
|
|
7622
7536
|
decisionKind: decision.kind,
|
|
7623
7537
|
emittedEventCount: combinedEvents.length
|
|
7624
7538
|
});
|
|
@@ -7640,7 +7554,7 @@ var LlmNode = class {
|
|
|
7640
7554
|
}
|
|
7641
7555
|
case "error": {
|
|
7642
7556
|
const { name, message, stack } = decision.error;
|
|
7643
|
-
|
|
7557
|
+
logger6.error("[LlmNode] Executor returned an error", { name, message, stack });
|
|
7644
7558
|
return { kind: "yield", events: combinedEvents };
|
|
7645
7559
|
}
|
|
7646
7560
|
default: {
|
|
@@ -7746,7 +7660,7 @@ async function resolveToolModelInput(input) {
|
|
|
7746
7660
|
}
|
|
7747
7661
|
|
|
7748
7662
|
// src/runtime-kernel/graph-engine/nodes/toolNode.finalAnswerProjector.ts
|
|
7749
|
-
function
|
|
7663
|
+
function readNonEmptyString4(value) {
|
|
7750
7664
|
if (typeof value !== "string") {
|
|
7751
7665
|
return void 0;
|
|
7752
7666
|
}
|
|
@@ -7754,7 +7668,7 @@ function readNonEmptyString5(value) {
|
|
|
7754
7668
|
return normalized.length > 0 ? normalized : void 0;
|
|
7755
7669
|
}
|
|
7756
7670
|
function resolveFinalAnswerFromToolControl(finalAnswer) {
|
|
7757
|
-
return
|
|
7671
|
+
return readNonEmptyString4(finalAnswer);
|
|
7758
7672
|
}
|
|
7759
7673
|
|
|
7760
7674
|
// src/runtime-kernel/graph-engine/nodes/toolNode.helpers.ts
|
|
@@ -8010,7 +7924,7 @@ function buildErrorLocalState(params) {
|
|
|
8010
7924
|
}
|
|
8011
7925
|
|
|
8012
7926
|
// src/runtime-kernel/tools/argNormalizer.ts
|
|
8013
|
-
var
|
|
7927
|
+
var logger7 = new Logger("ToolArgNormalizer");
|
|
8014
7928
|
function isRecord10(v) {
|
|
8015
7929
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
8016
7930
|
}
|
|
@@ -8030,7 +7944,7 @@ function joinPath(basePath, segment) {
|
|
|
8030
7944
|
function logJsonEncodedNormalization(expectedType, options) {
|
|
8031
7945
|
const toolPrefix = options.toolName ? `${options.toolName}.` : "";
|
|
8032
7946
|
const path = options.path ?? "<root>";
|
|
8033
|
-
|
|
7947
|
+
logger7.warn("normalized JSON-encoded tool argument", {
|
|
8034
7948
|
expectedType,
|
|
8035
7949
|
path: `${toolPrefix}${path}`
|
|
8036
7950
|
});
|
|
@@ -8326,7 +8240,7 @@ function ensureToolContextRuntimeCapability(params) {
|
|
|
8326
8240
|
}
|
|
8327
8241
|
|
|
8328
8242
|
// src/runtime-kernel/graph-engine/nodes/toolNode.eventBridge.ts
|
|
8329
|
-
var
|
|
8243
|
+
var logger8 = new Logger("ToolNode");
|
|
8330
8244
|
var ToolNodeEventBridge = class {
|
|
8331
8245
|
constructor(deps) {
|
|
8332
8246
|
this.deps = deps;
|
|
@@ -8348,7 +8262,7 @@ var ToolNodeEventBridge = class {
|
|
|
8348
8262
|
status,
|
|
8349
8263
|
payload: { ...payload }
|
|
8350
8264
|
};
|
|
8351
|
-
|
|
8265
|
+
logger8.info("[ToolNode] \u53D1\u51FA tool_process \u4E8B\u4EF6", {
|
|
8352
8266
|
phase,
|
|
8353
8267
|
status,
|
|
8354
8268
|
toolName: this.deps.toolName,
|
|
@@ -8388,7 +8302,7 @@ var ToolNodeEventBridge = class {
|
|
|
8388
8302
|
const answerId = generateAnswerSegmentId();
|
|
8389
8303
|
const id = answerId;
|
|
8390
8304
|
const timestamp = Date.now();
|
|
8391
|
-
|
|
8305
|
+
logger8.info("[ToolNode] \u5DE5\u5177\u8F93\u51FA\u6620\u5C04\u4E3A final_answer", {
|
|
8392
8306
|
sourceToolName: params.sourceToolName,
|
|
8393
8307
|
toolCallId: this.deps.toolCallId,
|
|
8394
8308
|
conversationId: this.deps.conversationId,
|
|
@@ -8446,7 +8360,7 @@ var ToolNodeEventBridge = class {
|
|
|
8446
8360
|
};
|
|
8447
8361
|
|
|
8448
8362
|
// src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
|
|
8449
|
-
var
|
|
8363
|
+
var logger9 = new Logger("ToolNode");
|
|
8450
8364
|
function parseToolArgs(call) {
|
|
8451
8365
|
const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
|
|
8452
8366
|
if (!rawArguments.trim()) {
|
|
@@ -8466,7 +8380,7 @@ function parseToolArgs(call) {
|
|
|
8466
8380
|
return { ok: true, value: parsed };
|
|
8467
8381
|
} catch (error) {
|
|
8468
8382
|
const reason = error instanceof Error ? error.message : "Unknown JSON parse error";
|
|
8469
|
-
|
|
8383
|
+
logger9.warn("failed to parse tool arguments", { error });
|
|
8470
8384
|
return {
|
|
8471
8385
|
ok: false,
|
|
8472
8386
|
error: `Tool arguments are not valid JSON: ${reason}`
|
|
@@ -8860,7 +8774,7 @@ async function claimPendingUserInputs(state, result) {
|
|
|
8860
8774
|
}
|
|
8861
8775
|
|
|
8862
8776
|
// src/runtime-kernel/graph-engine/nodes/toolNode.ts
|
|
8863
|
-
var
|
|
8777
|
+
var logger10 = new Logger("ToolNode");
|
|
8864
8778
|
function isAbortSignal(value) {
|
|
8865
8779
|
return value !== null && typeof value === "object" && "aborted" in value;
|
|
8866
8780
|
}
|
|
@@ -9073,7 +8987,7 @@ var ToolNode = class {
|
|
|
9073
8987
|
throw abortError;
|
|
9074
8988
|
}
|
|
9075
8989
|
const prepared = prepareToolNodeContext(state);
|
|
9076
|
-
|
|
8990
|
+
logger10.info("[ToolNode] \u5F00\u59CB\u6267\u884C\u5DE5\u5177\u8282\u70B9", {
|
|
9077
8991
|
conversationId: prepared.conversationId,
|
|
9078
8992
|
turnId: prepared.turnId,
|
|
9079
8993
|
pendingCallCount: calls.length
|
|
@@ -9088,7 +9002,7 @@ var ToolNode = class {
|
|
|
9088
9002
|
toolCatalog: this.toolRuntime
|
|
9089
9003
|
});
|
|
9090
9004
|
if (!execution) {
|
|
9091
|
-
|
|
9005
|
+
logger10.warn("no tool name found in call");
|
|
9092
9006
|
return { kind: "yield", events: [] };
|
|
9093
9007
|
}
|
|
9094
9008
|
if (typeof execution.protocolError === "string") {
|
|
@@ -9128,7 +9042,7 @@ var ToolNode = class {
|
|
|
9128
9042
|
call,
|
|
9129
9043
|
context: prepared.toolContext,
|
|
9130
9044
|
abortGraceMs: this.abortGraceMs,
|
|
9131
|
-
onAbandon: () =>
|
|
9045
|
+
onAbandon: () => logger10.warn("[ToolNode] \u5DE5\u5177\u672A\u5728\u505C\u6B62\u671F\u9650\u5185\u7ED3\u675F\uFF0C\u6309\u4E2D\u65AD\u5904\u7406\u5E76\u4E22\u5F03\u8FDF\u5230\u7ED3\u679C", {
|
|
9132
9046
|
toolName: execution.toolName,
|
|
9133
9047
|
toolCallId: execution.toolCallId,
|
|
9134
9048
|
conversationId: prepared.conversationId,
|
|
@@ -9298,7 +9212,7 @@ var ToolNode = class {
|
|
|
9298
9212
|
runtimeEvents: context.bridge.getRuntimeEvents()
|
|
9299
9213
|
});
|
|
9300
9214
|
if (control?.terminateRun) {
|
|
9301
|
-
|
|
9215
|
+
logger10.info("[ToolNode] \u6536\u5230 control.terminateRun\uFF0C\u6267\u884C\u5B8C\u5DE5\u5177\u540E\u76F4\u63A5 yield \u7ED3\u675F\u672C\u8F6E run", {
|
|
9302
9216
|
toolName: context.toolName,
|
|
9303
9217
|
toolCallId: context.toolCallId,
|
|
9304
9218
|
conversationId: context.conversationId,
|
|
@@ -9307,7 +9221,7 @@ var ToolNode = class {
|
|
|
9307
9221
|
return { kind: "yield", events: context.bridge.getRuntimeEvents() };
|
|
9308
9222
|
}
|
|
9309
9223
|
if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
|
|
9310
|
-
|
|
9224
|
+
logger10.info("[ToolNode] \u5DE5\u5177\u6279\u6B21\u5DF2\u7ED3\u7B97\uFF0C\u6309 Host \u7B56\u7565\u76F4\u63A5 yield", {
|
|
9311
9225
|
toolName: context.toolName,
|
|
9312
9226
|
toolCallId: context.toolCallId,
|
|
9313
9227
|
conversationId: context.conversationId,
|
|
@@ -9754,6 +9668,8 @@ var executor = z.object({
|
|
|
9754
9668
|
lastStepsHintThreshold: counter.optional(),
|
|
9755
9669
|
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
9756
9670
|
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
9671
|
+
// 已删除字段:0.45 及更早的 checkpoint 可能带 lastSuccessfulLlmModelId,0.46 及更早的可能带云端额度兜底留下的
|
|
9672
|
+
// runLockedModelId;照常接受,读入时丢弃(兜底已移除,恢复后按请求的模型继续)。
|
|
9757
9673
|
runLockedModelId: z.string().optional(),
|
|
9758
9674
|
lastSuccessfulLlmModelId: z.string().optional(),
|
|
9759
9675
|
llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
|
|
@@ -9764,7 +9680,7 @@ var executor = z.object({
|
|
|
9764
9680
|
committedCount: counter,
|
|
9765
9681
|
lastCommittedFingerprint: z.string().optional()
|
|
9766
9682
|
}).strict().optional()
|
|
9767
|
-
}).strict();
|
|
9683
|
+
}).strict().transform(({ lastSuccessfulLlmModelId: _retired, runLockedModelId: _retiredLock, ...state }) => state);
|
|
9768
9684
|
var checkpoint = z.object({
|
|
9769
9685
|
nodeId: z.string().min(1),
|
|
9770
9686
|
schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|
|
@@ -9826,7 +9742,7 @@ __export(execution_exports, {
|
|
|
9826
9742
|
});
|
|
9827
9743
|
|
|
9828
9744
|
// src/runtime-kernel/execution/event-bus.ts
|
|
9829
|
-
var
|
|
9745
|
+
var logger11 = new Logger("EventBus");
|
|
9830
9746
|
var TypedEventEmitter = class {
|
|
9831
9747
|
listeners = /* @__PURE__ */ new Map();
|
|
9832
9748
|
maxListeners = 10;
|
|
@@ -9834,7 +9750,7 @@ var TypedEventEmitter = class {
|
|
|
9834
9750
|
const listeners = this.getListeners(event);
|
|
9835
9751
|
listeners.add(listener);
|
|
9836
9752
|
if (listeners.size > this.maxListeners) {
|
|
9837
|
-
|
|
9753
|
+
logger11.warn("EventBus listener count exceeds configured max", {
|
|
9838
9754
|
event: String(event),
|
|
9839
9755
|
count: listeners.size,
|
|
9840
9756
|
maxListeners: this.maxListeners
|
|
@@ -9894,7 +9810,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9894
9810
|
super();
|
|
9895
9811
|
this.executionId = executionId;
|
|
9896
9812
|
this.setMaxListeners(30);
|
|
9897
|
-
|
|
9813
|
+
logger11.info(`EventBus created for execution ${this.executionId}`);
|
|
9898
9814
|
}
|
|
9899
9815
|
/**
|
|
9900
9816
|
* 发布一个事件到总线
|
|
@@ -9903,7 +9819,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9903
9819
|
publish(envelope) {
|
|
9904
9820
|
if (envelope.trace.execution_id !== this.executionId) {
|
|
9905
9821
|
const error = new Error("EventEnvelope execution_id does not match EventBus instance.");
|
|
9906
|
-
|
|
9822
|
+
logger11.error("Mismatched execution_id", {
|
|
9907
9823
|
busExecutionId: this.executionId,
|
|
9908
9824
|
eventExecutionId: envelope.trace.execution_id,
|
|
9909
9825
|
eventSeq: envelope.seq
|
|
@@ -9915,7 +9831,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9915
9831
|
const error = new Error(
|
|
9916
9832
|
"EventBus only accepts RuntimeEvent with formal run routing identity."
|
|
9917
9833
|
);
|
|
9918
|
-
|
|
9834
|
+
logger11.error("RuntimeEvent is missing formal run routing identity", {
|
|
9919
9835
|
executionId: this.executionId,
|
|
9920
9836
|
eventId: envelope.payload.id,
|
|
9921
9837
|
eventType: envelope.payload.type
|
|
@@ -9929,14 +9845,14 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9929
9845
|
* 关闭总线,清理所有监听器
|
|
9930
9846
|
*/
|
|
9931
9847
|
close() {
|
|
9932
|
-
|
|
9848
|
+
logger11.info(`Closing EventBus for execution ${this.executionId}`);
|
|
9933
9849
|
this.emit("close");
|
|
9934
9850
|
this.removeAllListeners();
|
|
9935
9851
|
}
|
|
9936
9852
|
};
|
|
9937
9853
|
|
|
9938
9854
|
// src/runtime-kernel/execution/sequencer.ts
|
|
9939
|
-
var
|
|
9855
|
+
var logger12 = new Logger("EventSequencer");
|
|
9940
9856
|
var EventSequencer = class {
|
|
9941
9857
|
executionId;
|
|
9942
9858
|
traceId;
|
|
@@ -9944,7 +9860,7 @@ var EventSequencer = class {
|
|
|
9944
9860
|
constructor(conversationId, traceId) {
|
|
9945
9861
|
this.executionId = generateExecutionId();
|
|
9946
9862
|
this.traceId = traceId || generateTraceId();
|
|
9947
|
-
|
|
9863
|
+
logger12.info(`EventSequencer created for conversation ${conversationId}`, {
|
|
9948
9864
|
executionId: this.executionId,
|
|
9949
9865
|
traceId: this.traceId
|
|
9950
9866
|
});
|
|
@@ -10757,7 +10673,7 @@ var ThoughtStreamSegmenter = class {
|
|
|
10757
10673
|
};
|
|
10758
10674
|
|
|
10759
10675
|
// src/runtime-kernel/llm/streaming-adapter.ts
|
|
10760
|
-
var
|
|
10676
|
+
var logger13 = new Logger("LlmCaller");
|
|
10761
10677
|
var CanonicalInferenceFailureError = class extends Error {
|
|
10762
10678
|
errorCode;
|
|
10763
10679
|
recoverable;
|
|
@@ -10981,7 +10897,7 @@ async function callLlmStream(params) {
|
|
|
10981
10897
|
} catch (error) {
|
|
10982
10898
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
10983
10899
|
if (normalized.name === "AbortError") {
|
|
10984
|
-
|
|
10900
|
+
logger13.info("Canonical inference \u6536\u5230\u53D6\u6D88\u7EC8\u6001\uFF0C\u4E0D\u53D1\u5E03\u666E\u901A error event", { modelId });
|
|
10985
10901
|
throw normalized;
|
|
10986
10902
|
}
|
|
10987
10903
|
const classification = ErrorClassifier.classify(normalized, {
|
|
@@ -11057,7 +10973,7 @@ var LlmRetryEpisode = class {
|
|
|
11057
10973
|
};
|
|
11058
10974
|
|
|
11059
10975
|
// src/runtime-kernel/llm/retry-fallback-routing.ts
|
|
11060
|
-
var
|
|
10976
|
+
var logger14 = new Logger("LlmCaller");
|
|
11061
10977
|
function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement, fallbackObserver, error, evaluateFallbackPromptCapacity2) {
|
|
11062
10978
|
deps.modelCatalog.getModelById(activeModelId);
|
|
11063
10979
|
const policyDecision = deps.policyEngine.decideOnError(error, {
|
|
@@ -11087,81 +11003,16 @@ function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement
|
|
|
11087
11003
|
reason: "no_eligible_fallback_candidate",
|
|
11088
11004
|
requiredPlacements: requirement.placements
|
|
11089
11005
|
});
|
|
11090
|
-
|
|
11006
|
+
logger14.warn("Policy\u8981\u6C42\u5207\u6362\u6A21\u578B\uFF0C\u4F46\u672A\u627E\u5230\u53EF\u7528\u5907\u7528\u6A21\u578B\uFF08\u53EF\u80FD\u672A\u914D\u7F6E API Key\uFF09");
|
|
11091
11007
|
return null;
|
|
11092
11008
|
}
|
|
11093
|
-
|
|
11009
|
+
logger14.warn("Policy \u5207\u6362\u6A21\u578B\u7EE7\u7EED", {
|
|
11094
11010
|
reason: policyDecision.reason,
|
|
11095
11011
|
activeModelId,
|
|
11096
11012
|
fallbackModelId
|
|
11097
11013
|
});
|
|
11098
11014
|
return fallbackModelId;
|
|
11099
11015
|
}
|
|
11100
|
-
function tryCloudQuotaFallback({
|
|
11101
|
-
deps,
|
|
11102
|
-
activeModelId,
|
|
11103
|
-
options,
|
|
11104
|
-
excludedModelIds,
|
|
11105
|
-
requirement,
|
|
11106
|
-
error,
|
|
11107
|
-
fallbackObserver,
|
|
11108
|
-
evaluateFallbackPromptCapacity: evaluateFallbackPromptCapacity2
|
|
11109
|
-
}) {
|
|
11110
|
-
const fallbackModelId = options.cloud_quota_fallback_model_id;
|
|
11111
|
-
if (!fallbackModelId || !ErrorClassifier.isCloudQuotaError(error) || excludedModelIds.has(fallbackModelId)) {
|
|
11112
|
-
return null;
|
|
11113
|
-
}
|
|
11114
|
-
const fallbackConfig = deps.modelCatalog.getModelById(fallbackModelId);
|
|
11115
|
-
if (!fallbackConfig?.api_key) {
|
|
11116
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11117
|
-
fromModelId: activeModelId,
|
|
11118
|
-
candidateModelId: fallbackModelId,
|
|
11119
|
-
policy: "cloud-quota",
|
|
11120
|
-
reason: "fallback_model_unavailable",
|
|
11121
|
-
requiredPlacements: requirement.placements
|
|
11122
|
-
});
|
|
11123
|
-
logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u53EF\u7528\uFF08\u672A\u6CE8\u518C\u6216\u7F3A\u5C11 API Key\uFF09", { fallbackModelId });
|
|
11124
|
-
return null;
|
|
11125
|
-
}
|
|
11126
|
-
const compatibility = evaluateModelInputCompatibility(fallbackConfig, requirement);
|
|
11127
|
-
if (!compatibility.compatible) {
|
|
11128
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11129
|
-
fromModelId: activeModelId,
|
|
11130
|
-
candidateModelId: fallbackModelId,
|
|
11131
|
-
policy: "cloud-quota",
|
|
11132
|
-
reason: compatibility.reason,
|
|
11133
|
-
requiredPlacements: requirement.placements
|
|
11134
|
-
});
|
|
11135
|
-
logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u6EE1\u8DB3\u5F53\u524D\u8F93\u5165\u80FD\u529B\uFF0C\u4FDD\u7559\u539F\u59CB\u9519\u8BEF", {
|
|
11136
|
-
fallbackModelId,
|
|
11137
|
-
requiredPlacements: requirement.placements,
|
|
11138
|
-
reason: compatibility.reason
|
|
11139
|
-
});
|
|
11140
|
-
return null;
|
|
11141
|
-
}
|
|
11142
|
-
const capacityAdmission = evaluateFallbackPromptCapacity2?.(fallbackModelId);
|
|
11143
|
-
if (capacityAdmission && !capacityAdmission.admitted) {
|
|
11144
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11145
|
-
fromModelId: activeModelId,
|
|
11146
|
-
candidateModelId: fallbackModelId,
|
|
11147
|
-
policy: "cloud-quota",
|
|
11148
|
-
reason: capacityAdmission.reason,
|
|
11149
|
-
requiredPlacements: requirement.placements
|
|
11150
|
-
});
|
|
11151
|
-
logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u6EE1\u8DB3\u5F53\u524D Prompt \u5BB9\u91CF\u8981\u6C42\uFF0C\u4FDD\u7559\u539F\u59CB\u9519\u8BEF", {
|
|
11152
|
-
fallbackModelId,
|
|
11153
|
-
reason: capacityAdmission.reason
|
|
11154
|
-
});
|
|
11155
|
-
return null;
|
|
11156
|
-
}
|
|
11157
|
-
logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\uFF08run \u5185\u7EED\u8DD1\uFF09", {
|
|
11158
|
-
activeModelId,
|
|
11159
|
-
fallbackModelId,
|
|
11160
|
-
reason: error.message
|
|
11161
|
-
});
|
|
11162
|
-
fallbackObserver?.onCloudQuotaFallbackApplied?.(fallbackModelId);
|
|
11163
|
-
return fallbackModelId;
|
|
11164
|
-
}
|
|
11165
11016
|
|
|
11166
11017
|
// src/runtime-kernel/llm/usage-telemetry.ts
|
|
11167
11018
|
async function callPlainCompletion(inferencePort, modelId, messages, options = {}, signal, traceId) {
|
|
@@ -11264,7 +11115,7 @@ async function runLlmInputPreflight(params) {
|
|
|
11264
11115
|
}
|
|
11265
11116
|
|
|
11266
11117
|
// src/runtime-kernel/llm/retry-fallback.ts
|
|
11267
|
-
var
|
|
11118
|
+
var logger15 = new Logger("LlmCaller");
|
|
11268
11119
|
async function callWithRetryFallback(params) {
|
|
11269
11120
|
const {
|
|
11270
11121
|
deps,
|
|
@@ -11292,11 +11143,9 @@ async function callWithRetryFallback(params) {
|
|
|
11292
11143
|
const retryEpisode = new LlmRetryEpisode(traceId, eventHandler);
|
|
11293
11144
|
let previousAttemptTracker;
|
|
11294
11145
|
if (!clientRetryEnabled) {
|
|
11295
|
-
|
|
11296
|
-
logger16.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
|
|
11146
|
+
logger15.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
|
|
11297
11147
|
modelId,
|
|
11298
|
-
|
|
11299
|
-
reason: options.retry_policy === "none" ? "options.retry_policy=none" : "model config (cloud billing or enable_client_retry=false)"
|
|
11148
|
+
reason: options.retry_policy === "none" ? "options.retry_policy=none" : "model config enable_client_retry=false"
|
|
11300
11149
|
});
|
|
11301
11150
|
}
|
|
11302
11151
|
try {
|
|
@@ -11332,7 +11181,7 @@ async function callWithRetryFallback(params) {
|
|
|
11332
11181
|
}) : void 0;
|
|
11333
11182
|
try {
|
|
11334
11183
|
if (isRetry) {
|
|
11335
|
-
|
|
11184
|
+
logger15.info("LLM \u8C03\u7528\u91CD\u8BD5", { attempt, configuredMaxRetries });
|
|
11336
11185
|
}
|
|
11337
11186
|
actualAttempts++;
|
|
11338
11187
|
retryEpisode.retrying(actualAttempts);
|
|
@@ -11361,7 +11210,7 @@ async function callWithRetryFallback(params) {
|
|
|
11361
11210
|
if (deps.retryConfig.enableEmptyResponseRetry && !responseContent?.trim() && !toolCallsFromLLM?.length) {
|
|
11362
11211
|
throw new Error("LLM\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94");
|
|
11363
11212
|
}
|
|
11364
|
-
|
|
11213
|
+
logger15.debug("LLM \u8C03\u7528\u6210\u529F", { attempts: actualAttempts, maxTotalAttempts });
|
|
11365
11214
|
if (attemptContextUsage) {
|
|
11366
11215
|
fallbackObserver?.onLlmAttemptSucceeded?.(activeModelId, attemptContextUsage);
|
|
11367
11216
|
} else {
|
|
@@ -11372,7 +11221,7 @@ async function callWithRetryFallback(params) {
|
|
|
11372
11221
|
} catch (error) {
|
|
11373
11222
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
11374
11223
|
if (lastError.name === "AbortError") {
|
|
11375
|
-
|
|
11224
|
+
logger15.info("LLM \u8C03\u7528\u5DF2\u53D6\u6D88\uFF0C\u4E0D\u8FDB\u5165 provider failure \u5206\u7C7B\u4E0E\u91CD\u8BD5\u6D41\u7A0B", {
|
|
11376
11225
|
attempt: attempt + 1,
|
|
11377
11226
|
actualAttempts,
|
|
11378
11227
|
maxTotalAttempts,
|
|
@@ -11391,7 +11240,7 @@ async function callWithRetryFallback(params) {
|
|
|
11391
11240
|
total_attempts: actualAttempts,
|
|
11392
11241
|
error_code: classification.errorCode
|
|
11393
11242
|
};
|
|
11394
|
-
|
|
11243
|
+
logger15.error("LLM \u8C03\u7528\u5931\u8D25", {
|
|
11395
11244
|
attempt: attempt + 1,
|
|
11396
11245
|
maxAttempts: currentMaxRetries + 1,
|
|
11397
11246
|
actualAttempts,
|
|
@@ -11400,7 +11249,7 @@ async function callWithRetryFallback(params) {
|
|
|
11400
11249
|
});
|
|
11401
11250
|
previousAttemptTracker = attemptTracker;
|
|
11402
11251
|
if (!hasLlmAttemptBudgetRemaining({ actualAttempts, maxTotalAttempts })) {
|
|
11403
|
-
|
|
11252
|
+
logger15.error("\u5DF2\u8FBE\u5230 LLM \u603B\u8C03\u7528\u6B21\u6570\u4E0A\u9650\uFF0C\u505C\u6B62\u91CD\u8BD5/\u5207\u6A21\u578B", {
|
|
11404
11253
|
actualAttempts,
|
|
11405
11254
|
maxTotalAttempts
|
|
11406
11255
|
});
|
|
@@ -11430,37 +11279,15 @@ async function callWithRetryFallback(params) {
|
|
|
11430
11279
|
attempt -= 1;
|
|
11431
11280
|
continue;
|
|
11432
11281
|
}
|
|
11433
|
-
const quotaFallbackModelId = tryCloudQuotaFallback({
|
|
11434
|
-
deps,
|
|
11435
|
-
activeModelId,
|
|
11436
|
-
options,
|
|
11437
|
-
excludedModelIds,
|
|
11438
|
-
requirement,
|
|
11439
|
-
error: lastError,
|
|
11440
|
-
fallbackObserver,
|
|
11441
|
-
evaluateFallbackPromptCapacity: invocationContext?.evaluateFallbackPromptCapacity
|
|
11442
|
-
});
|
|
11443
|
-
if (quotaFallbackModelId) {
|
|
11444
|
-
fallbackObserver?.onModelFallbackApplied?.({
|
|
11445
|
-
fromModelId: activeModelId,
|
|
11446
|
-
toModelId: quotaFallbackModelId,
|
|
11447
|
-
reason: lastError.message,
|
|
11448
|
-
policy: "cloud-quota"
|
|
11449
|
-
});
|
|
11450
|
-
activeModelId = quotaFallbackModelId;
|
|
11451
|
-
excludedModelIds.add(quotaFallbackModelId);
|
|
11452
|
-
attempt -= 1;
|
|
11453
|
-
continue;
|
|
11454
|
-
}
|
|
11455
11282
|
}
|
|
11456
11283
|
if (classification.category === "non_retryable" /* NON_RETRYABLE */) {
|
|
11457
|
-
|
|
11284
|
+
logger15.error("\u9519\u8BEF\u4E0D\u53EF\u91CD\u8BD5\uFF0C\u76F4\u63A5\u5931\u8D25", { reason: classification.reason });
|
|
11458
11285
|
retryEpisode.finish("failed", failedRetryState);
|
|
11459
11286
|
emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
|
|
11460
11287
|
throw lastError;
|
|
11461
11288
|
}
|
|
11462
11289
|
if (attempt >= configuredMaxRetries || categoryRetries[category] >= currentMaxRetries) {
|
|
11463
|
-
|
|
11290
|
+
logger15.error("\u5DF2\u8FBE\u5230\u6700\u5927\u91CD\u8BD5\u6B21\u6570\uFF0C\u653E\u5F03\u91CD\u8BD5", { maxRetries: currentMaxRetries });
|
|
11464
11291
|
retryEpisode.finish("exhausted", failedRetryState);
|
|
11465
11292
|
emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
|
|
11466
11293
|
throw lastError;
|
|
@@ -11472,9 +11299,9 @@ async function callWithRetryFallback(params) {
|
|
|
11472
11299
|
6e4
|
|
11473
11300
|
);
|
|
11474
11301
|
if (classification.category === "rate_limit" /* RATE_LIMIT */) {
|
|
11475
|
-
|
|
11302
|
+
logger15.warn("\u901F\u7387\u9650\u5236\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
|
|
11476
11303
|
} else if (classification.category === "retryable" /* RETRYABLE */) {
|
|
11477
|
-
|
|
11304
|
+
logger15.warn("\u53EF\u91CD\u8BD5\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
|
|
11478
11305
|
}
|
|
11479
11306
|
throwIfAborted(signal, "\u5EF6\u8FDF\u7B49\u5F85\u524D\u68C0\u6D4B\u5230\u53D6\u6D88\u4FE1\u53F7\uFF0C\u505C\u6B62\u91CD\u8BD5");
|
|
11480
11307
|
categoryRetries[category] += 1;
|
|
@@ -11511,16 +11338,11 @@ function waitForRetry(delayMs, signal) {
|
|
|
11511
11338
|
}
|
|
11512
11339
|
function isClientRetryEnabledForModel(modelCatalog, modelId, options) {
|
|
11513
11340
|
if (options.retry_policy === "none") return false;
|
|
11514
|
-
|
|
11515
|
-
if (cfg?.billing_mode === "cloud") return false;
|
|
11516
|
-
if (options.retry_policy === "client") return true;
|
|
11517
|
-
if (!cfg) return true;
|
|
11518
|
-
if (cfg.enable_client_retry === false) return false;
|
|
11519
|
-
return true;
|
|
11341
|
+
return modelCatalog.getModelById(modelId)?.enable_client_retry !== false;
|
|
11520
11342
|
}
|
|
11521
11343
|
function throwIfAborted(signal, message) {
|
|
11522
11344
|
if (!signal?.aborted) return;
|
|
11523
|
-
|
|
11345
|
+
logger15.info(message);
|
|
11524
11346
|
const reason = signal.reason;
|
|
11525
11347
|
if (reason instanceof Error && reason.name === "AbortError") throw reason;
|
|
11526
11348
|
const reasonText = typeof reason === "string" && reason.trim().length > 0 ? reason : "stream_interrupted";
|
|
@@ -12203,7 +12025,7 @@ function runMetaFromRecord(record) {
|
|
|
12203
12025
|
}
|
|
12204
12026
|
|
|
12205
12027
|
// src/runtime-kernel/run-supervisor/functions/awaitingUserWatcher.ts
|
|
12206
|
-
var
|
|
12028
|
+
var logger17 = new Logger("RunSupervisorAwaitingUserWatcher");
|
|
12207
12029
|
function isRecord16(value) {
|
|
12208
12030
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12209
12031
|
}
|
|
@@ -12248,7 +12070,7 @@ function createAwaitingUserWatcher(options) {
|
|
|
12248
12070
|
resumeToken: event.resume_token
|
|
12249
12071
|
}
|
|
12250
12072
|
}).catch((error) => {
|
|
12251
|
-
|
|
12073
|
+
logger17.warn("failed to mark awaiting_user from requires_user_interaction", { error });
|
|
12252
12074
|
});
|
|
12253
12075
|
};
|
|
12254
12076
|
const dispose = () => {
|