@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/cli.js
CHANGED
|
@@ -2218,18 +2218,6 @@ var ErrorClassifier = class {
|
|
|
2218
2218
|
});
|
|
2219
2219
|
}
|
|
2220
2220
|
}
|
|
2221
|
-
const quotaPatterns = ["\u5DF2\u8FBE\u4E0A\u9650", "\u514D\u8D39\u671F\u5DF2\u7ED3\u675F"];
|
|
2222
|
-
for (const pattern of quotaPatterns) {
|
|
2223
|
-
if (errorMessage.includes(pattern)) {
|
|
2224
|
-
logClassification(context, "\u68C0\u6D4B\u5230\u4E91\u7AEF\u989D\u5EA6\u9650\u5236\uFF0C\u4E0D\u91CD\u8BD5", { matchedPattern: pattern });
|
|
2225
|
-
return createClassification("non_retryable" /* NON_RETRYABLE */, `\u4E91\u7AEF\u989D\u5EA6\u9650\u5236: ${pattern}`, null, {
|
|
2226
|
-
errorCode: ENGINE_ERROR_CODES.LLM_PROVIDER_DOWN,
|
|
2227
|
-
recoverable: false,
|
|
2228
|
-
hint: "check_billing_or_provider_status",
|
|
2229
|
-
metadata: { matchedPattern: pattern }
|
|
2230
|
-
});
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
2221
|
const authPatterns = [
|
|
2234
2222
|
{ pattern: "unauthorized", code: "401" },
|
|
2235
2223
|
{ pattern: "forbidden", code: "403" },
|
|
@@ -2484,17 +2472,6 @@ var ErrorClassifier = class {
|
|
|
2484
2472
|
}
|
|
2485
2473
|
return Math.max(baseDelay, classification.suggestedDelay ?? 0);
|
|
2486
2474
|
}
|
|
2487
|
-
static isCloudQuotaError(error) {
|
|
2488
|
-
const msg = (error.message || "").toLowerCase();
|
|
2489
|
-
const patterns = [
|
|
2490
|
-
"\u989D\u5EA6\u4E0A\u9650",
|
|
2491
|
-
"\u5DF2\u8FBE\u4E0A\u9650",
|
|
2492
|
-
"\u514D\u8D39\u671F\u5DF2\u7ED3\u675F",
|
|
2493
|
-
"\u8BE5\u6A21\u578B\u6682\u4E0D\u53EF\u7528",
|
|
2494
|
-
"cloud_quota_exhausted"
|
|
2495
|
-
];
|
|
2496
|
-
return patterns.some((pattern) => msg.includes(pattern));
|
|
2497
|
-
}
|
|
2498
2475
|
};
|
|
2499
2476
|
|
|
2500
2477
|
// src/shared/engineErrorEvent.ts
|
|
@@ -3978,8 +3955,8 @@ var TokenCalculator = class {
|
|
|
3978
3955
|
return;
|
|
3979
3956
|
}
|
|
3980
3957
|
this.failedEncodingWarnings.add(requestedEncoding);
|
|
3981
|
-
const
|
|
3982
|
-
|
|
3958
|
+
const logger18 = new Logger("TokenCalculator");
|
|
3959
|
+
logger18.warn("tiktoken encoding unavailable, falling back to avgCharsPerToken estimator", {
|
|
3983
3960
|
requestedEncoding,
|
|
3984
3961
|
error
|
|
3985
3962
|
});
|
|
@@ -4071,49 +4048,6 @@ var llmTelemetryMiddleware = async (ctx, stage, next) => {
|
|
|
4071
4048
|
});
|
|
4072
4049
|
};
|
|
4073
4050
|
|
|
4074
|
-
// src/runtime-kernel/graph-engine/functions/runModelLock.ts
|
|
4075
|
-
function readNonEmptyString4(value) {
|
|
4076
|
-
if (typeof value !== "string") return void 0;
|
|
4077
|
-
const trimmed = value.trim();
|
|
4078
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
4079
|
-
}
|
|
4080
|
-
function decideRunModelLockPatch(params) {
|
|
4081
|
-
if (params.stageId !== "execute_llm") {
|
|
4082
|
-
return { shouldLog: false };
|
|
4083
|
-
}
|
|
4084
|
-
const normalized = readNonEmptyString4(params.appliedFallbackModelId);
|
|
4085
|
-
if (!normalized) {
|
|
4086
|
-
return { shouldLog: false };
|
|
4087
|
-
}
|
|
4088
|
-
if (readNonEmptyString4(params.currentRunLockedModelId) === normalized) {
|
|
4089
|
-
return { shouldLog: false };
|
|
4090
|
-
}
|
|
4091
|
-
return {
|
|
4092
|
-
executorLocalPatch: { runLockedModelId: normalized },
|
|
4093
|
-
shouldLog: true
|
|
4094
|
-
};
|
|
4095
|
-
}
|
|
4096
|
-
|
|
4097
|
-
// src/runtime-kernel/graph-engine/tick-pipeline/middlewares/runModelLockMiddleware.ts
|
|
4098
|
-
var logger4 = new Logger("GraphAgentExecutor");
|
|
4099
|
-
var runModelLockMiddleware = async (ctx, stage, next) => {
|
|
4100
|
-
await next();
|
|
4101
|
-
const decision = decideRunModelLockPatch({
|
|
4102
|
-
stageId: stage.id,
|
|
4103
|
-
appliedFallbackModelId: ctx.cloudQuotaFallbackAppliedModelId,
|
|
4104
|
-
currentRunLockedModelId: ctx.executorLocalPatch?.runLockedModelId ?? ctx.executorLocal?.runLockedModelId
|
|
4105
|
-
});
|
|
4106
|
-
if (!decision.executorLocalPatch) {
|
|
4107
|
-
return;
|
|
4108
|
-
}
|
|
4109
|
-
if (decision.shouldLog) {
|
|
4110
|
-
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}`);
|
|
4111
|
-
}
|
|
4112
|
-
return {
|
|
4113
|
-
executorLocalPatch: decision.executorLocalPatch
|
|
4114
|
-
};
|
|
4115
|
-
};
|
|
4116
|
-
|
|
4117
4051
|
// src/runtime-kernel/graph-engine/tick-pipeline/runTickPipeline.ts
|
|
4118
4052
|
var tickPipelineContextKeys = [
|
|
4119
4053
|
"input",
|
|
@@ -4149,7 +4083,6 @@ var tickPipelineContextKeys = [
|
|
|
4149
4083
|
"decision",
|
|
4150
4084
|
"systemReminderHitRuleIds",
|
|
4151
4085
|
"contextTrace",
|
|
4152
|
-
"cloudQuotaFallbackAppliedModelId",
|
|
4153
4086
|
"modelFallbackAudit",
|
|
4154
4087
|
"telemetry",
|
|
4155
4088
|
"audit",
|
|
@@ -4488,7 +4421,7 @@ ${normalized}
|
|
|
4488
4421
|
}
|
|
4489
4422
|
|
|
4490
4423
|
// src/runtime-kernel/system-reminder/apply.ts
|
|
4491
|
-
var
|
|
4424
|
+
var logger4 = new Logger("SystemReminder");
|
|
4492
4425
|
var readString2 = (v) => {
|
|
4493
4426
|
if (typeof v !== "string") return void 0;
|
|
4494
4427
|
const s = v;
|
|
@@ -4551,7 +4484,7 @@ function applySystemReminders(params) {
|
|
|
4551
4484
|
} catch {
|
|
4552
4485
|
}
|
|
4553
4486
|
}
|
|
4554
|
-
|
|
4487
|
+
logger4.info("SystemReminder \u5DF2\u6CE8\u5165\u5230 LLM \u8F93\u5165\u672B\u5C3E", {
|
|
4555
4488
|
ruleIds: injectedRuleIds.length > 0 ? injectedRuleIds : Array.from(seenRuleIds),
|
|
4556
4489
|
promptKey: ctx.request.promptKey,
|
|
4557
4490
|
executorLocal: {
|
|
@@ -5043,18 +4976,14 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5043
4976
|
"turnId"
|
|
5044
4977
|
],
|
|
5045
4978
|
writes: [
|
|
5046
|
-
"cloudQuotaFallbackAppliedModelId",
|
|
5047
4979
|
"modelFallbackAudit",
|
|
5048
4980
|
"llmCallStartedAt",
|
|
5049
4981
|
"llmResp",
|
|
5050
4982
|
"llmCallDurationMs",
|
|
5051
|
-
"executorLocalPatch",
|
|
5052
4983
|
"contextUsage"
|
|
5053
4984
|
],
|
|
5054
4985
|
async run(ctx) {
|
|
5055
|
-
let cloudQuotaFallbackAppliedModelId;
|
|
5056
4986
|
let modelFallbackAudit;
|
|
5057
|
-
let lastSuccessfulLlmModelId;
|
|
5058
4987
|
let contextUsage;
|
|
5059
4988
|
const modelFallbackRejections = [];
|
|
5060
4989
|
const promptBudget = ctx.promptBudget;
|
|
@@ -5072,11 +5001,7 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5072
5001
|
streamEventHandler,
|
|
5073
5002
|
ctx.signal,
|
|
5074
5003
|
{
|
|
5075
|
-
|
|
5076
|
-
cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
|
|
5077
|
-
},
|
|
5078
|
-
onLlmAttemptSucceeded(activeModelId, attemptContextUsage) {
|
|
5079
|
-
lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
|
|
5004
|
+
onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
|
|
5080
5005
|
contextUsage = attemptContextUsage;
|
|
5081
5006
|
},
|
|
5082
5007
|
onModelFallbackApplied(info) {
|
|
@@ -5172,12 +5097,10 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5172
5097
|
});
|
|
5173
5098
|
}
|
|
5174
5099
|
return {
|
|
5175
|
-
cloudQuotaFallbackAppliedModelId,
|
|
5176
5100
|
modelFallbackAudit,
|
|
5177
5101
|
llmCallStartedAt,
|
|
5178
5102
|
llmResp,
|
|
5179
5103
|
llmCallDurationMs,
|
|
5180
|
-
executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
|
|
5181
5104
|
contextUsage
|
|
5182
5105
|
};
|
|
5183
5106
|
}
|
|
@@ -6094,18 +6017,16 @@ function createPrepareCallStage(dependencies) {
|
|
|
6094
6017
|
"toolDefinitionTokens"
|
|
6095
6018
|
],
|
|
6096
6019
|
async run(ctx) {
|
|
6097
|
-
const
|
|
6098
|
-
const requestedModelId = lockedRunModelId ?? ctx.request.model_id;
|
|
6020
|
+
const requestedModelId = ctx.request.model_id;
|
|
6099
6021
|
const modelId = dependencies.modelResolver.resolveModelId(requestedModelId);
|
|
6100
6022
|
await emitAuditEnvelope(ctx.audit, {
|
|
6101
6023
|
action: "model.select",
|
|
6102
6024
|
actor: { kind: "system" },
|
|
6103
6025
|
decision: {
|
|
6104
6026
|
outcome: "recorded",
|
|
6105
|
-
reason:
|
|
6027
|
+
reason: requestedModelId ? "request model id" : "default model resolver",
|
|
6106
6028
|
metadata: {
|
|
6107
6029
|
requestedModelId,
|
|
6108
|
-
lockedRunModelId,
|
|
6109
6030
|
selectedModelId: modelId
|
|
6110
6031
|
}
|
|
6111
6032
|
},
|
|
@@ -6152,10 +6073,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6152
6073
|
if (ctx.executorLocal?.lockRequestedModelId === true) {
|
|
6153
6074
|
llmOptions.allow_model_fallback = false;
|
|
6154
6075
|
}
|
|
6155
|
-
const isRunContinuation = ctx.executorLocal?.llmInvocationKind === "continuation";
|
|
6156
|
-
if (dependencies.cloudQuotaFallbackModelId && modelConfig?.billing_mode === "cloud" && modelId !== dependencies.cloudQuotaFallbackModelId && isRunContinuation && ctx.executorLocal?.lockRequestedModelId !== true) {
|
|
6157
|
-
llmOptions.cloud_quota_fallback_model_id = dependencies.cloudQuotaFallbackModelId;
|
|
6158
|
-
}
|
|
6159
6076
|
const effectiveEffort = resolveEffectiveEffort(
|
|
6160
6077
|
ctx.request.reasoning_effort,
|
|
6161
6078
|
modelConfig?.reasoning
|
|
@@ -6272,12 +6189,11 @@ function applyCalibration(rawLocalTotal, imageInputTokens, coefficient) {
|
|
|
6272
6189
|
}
|
|
6273
6190
|
|
|
6274
6191
|
// src/runtime-kernel/graph-engine/executor.ts
|
|
6275
|
-
var
|
|
6192
|
+
var logger5 = new Logger("GraphAgentExecutor");
|
|
6276
6193
|
var GraphAgentExecutor = class {
|
|
6277
6194
|
llmCaller;
|
|
6278
6195
|
toolRuntime;
|
|
6279
6196
|
contextBuilder;
|
|
6280
|
-
cloudQuotaFallbackModelId;
|
|
6281
6197
|
modelResolver;
|
|
6282
6198
|
modelCatalog;
|
|
6283
6199
|
telemetryPort;
|
|
@@ -6289,7 +6205,6 @@ var GraphAgentExecutor = class {
|
|
|
6289
6205
|
this.llmCaller = dependencies.llmCaller;
|
|
6290
6206
|
this.toolRuntime = dependencies.toolRuntime;
|
|
6291
6207
|
this.contextBuilder = dependencies.contextBuilder;
|
|
6292
|
-
this.cloudQuotaFallbackModelId = readNonEmptyString3(dependencies.cloudQuotaFallbackModelId);
|
|
6293
6208
|
this.modelCatalog = dependencies.modelCatalog ?? createEmptyModelCatalog();
|
|
6294
6209
|
this.modelResolver = dependencies.modelResolver ?? new ModelResolver({
|
|
6295
6210
|
modelCatalog: this.modelCatalog
|
|
@@ -6306,8 +6221,7 @@ var GraphAgentExecutor = class {
|
|
|
6306
6221
|
createPrepareCallStage({
|
|
6307
6222
|
modelResolver: this.modelResolver,
|
|
6308
6223
|
modelCatalog: this.modelCatalog,
|
|
6309
|
-
toolCatalog: this.toolRuntime
|
|
6310
|
-
cloudQuotaFallbackModelId: this.cloudQuotaFallbackModelId
|
|
6224
|
+
toolCatalog: this.toolRuntime
|
|
6311
6225
|
}),
|
|
6312
6226
|
createBuildContextStage({
|
|
6313
6227
|
contextBuilder: this.contextBuilder
|
|
@@ -6329,7 +6243,7 @@ var GraphAgentExecutor = class {
|
|
|
6329
6243
|
}),
|
|
6330
6244
|
createBuildDecisionStage()
|
|
6331
6245
|
];
|
|
6332
|
-
this.middlewares = [llmTelemetryMiddleware
|
|
6246
|
+
this.middlewares = [llmTelemetryMiddleware];
|
|
6333
6247
|
}
|
|
6334
6248
|
async tick(input, eventHandler) {
|
|
6335
6249
|
const ctx = {
|
|
@@ -6354,7 +6268,7 @@ var GraphAgentExecutor = class {
|
|
|
6354
6268
|
audit: this.auditPort,
|
|
6355
6269
|
tokenizer: this.tokenizer
|
|
6356
6270
|
};
|
|
6357
|
-
|
|
6271
|
+
logger5.info("[GraphAgentExecutor] tick \u8C03\u7528", {
|
|
6358
6272
|
stream: input.stream === true,
|
|
6359
6273
|
hasEventHandler: Boolean(eventHandler),
|
|
6360
6274
|
hasSummarizationCallbacks: Boolean(input.summarizationCallbacks)
|
|
@@ -7377,7 +7291,7 @@ var LlmNodeEventBridge = class {
|
|
|
7377
7291
|
};
|
|
7378
7292
|
|
|
7379
7293
|
// src/runtime-kernel/graph-engine/nodes/llmNode.ts
|
|
7380
|
-
var
|
|
7294
|
+
var logger6 = new Logger("LlmNode");
|
|
7381
7295
|
var LlmNode = class {
|
|
7382
7296
|
id = "llm";
|
|
7383
7297
|
reasoner;
|
|
@@ -7386,7 +7300,7 @@ var LlmNode = class {
|
|
|
7386
7300
|
}
|
|
7387
7301
|
async run(state) {
|
|
7388
7302
|
const local = state.local ?? {};
|
|
7389
|
-
|
|
7303
|
+
logger6.info("[LlmNode] \u5F00\u59CB\u6267\u884C LLM \u8282\u70B9", {
|
|
7390
7304
|
localKeys: Object.keys(local)
|
|
7391
7305
|
});
|
|
7392
7306
|
const graphLocal = readGraphAgentLocal(state.local);
|
|
@@ -7401,12 +7315,12 @@ var LlmNode = class {
|
|
|
7401
7315
|
signal,
|
|
7402
7316
|
history
|
|
7403
7317
|
} = graphLocal;
|
|
7404
|
-
|
|
7318
|
+
logger6.info("[LlmNode] \u5DF2\u52A0\u8F7D\u5386\u53F2\u4E8B\u4EF6", {
|
|
7405
7319
|
historyCount: history.length,
|
|
7406
7320
|
hasSummarizationCallbacks: Boolean(summarizationCallbacks)
|
|
7407
7321
|
});
|
|
7408
7322
|
if (!request) {
|
|
7409
|
-
|
|
7323
|
+
logger6.warn("Request object is missing, yielding.");
|
|
7410
7324
|
return { kind: "yield", events: [] };
|
|
7411
7325
|
}
|
|
7412
7326
|
const turnId = requireRuntimeIdentity(graphLocal.turnId, "turnId");
|
|
@@ -7499,12 +7413,12 @@ var LlmNode = class {
|
|
|
7499
7413
|
...nodeState.streamRuntimeEvents,
|
|
7500
7414
|
...contextUsageEvent ? [contextUsageEvent] : []
|
|
7501
7415
|
];
|
|
7502
|
-
|
|
7416
|
+
logger6.info("[LlmNode] \u5386\u53F2\u4E8B\u4EF6\u5DF2\u66F4\u65B0", {
|
|
7503
7417
|
previousCount: history.length,
|
|
7504
7418
|
nextCount: patch.history.length,
|
|
7505
7419
|
streamedEventCount: nodeState.streamRuntimeEvents.length
|
|
7506
7420
|
});
|
|
7507
|
-
|
|
7421
|
+
logger6.info("[LlmNode] \u6267\u884C\u5668\u51B3\u7B56\u5B8C\u6210", {
|
|
7508
7422
|
decisionKind: decision.kind,
|
|
7509
7423
|
emittedEventCount: combinedEvents.length
|
|
7510
7424
|
});
|
|
@@ -7526,7 +7440,7 @@ var LlmNode = class {
|
|
|
7526
7440
|
}
|
|
7527
7441
|
case "error": {
|
|
7528
7442
|
const { name, message, stack } = decision.error;
|
|
7529
|
-
|
|
7443
|
+
logger6.error("[LlmNode] Executor returned an error", { name, message, stack });
|
|
7530
7444
|
return { kind: "yield", events: combinedEvents };
|
|
7531
7445
|
}
|
|
7532
7446
|
default: {
|
|
@@ -7632,7 +7546,7 @@ async function resolveToolModelInput(input) {
|
|
|
7632
7546
|
}
|
|
7633
7547
|
|
|
7634
7548
|
// src/runtime-kernel/graph-engine/nodes/toolNode.finalAnswerProjector.ts
|
|
7635
|
-
function
|
|
7549
|
+
function readNonEmptyString4(value) {
|
|
7636
7550
|
if (typeof value !== "string") {
|
|
7637
7551
|
return void 0;
|
|
7638
7552
|
}
|
|
@@ -7640,7 +7554,7 @@ function readNonEmptyString5(value) {
|
|
|
7640
7554
|
return normalized.length > 0 ? normalized : void 0;
|
|
7641
7555
|
}
|
|
7642
7556
|
function resolveFinalAnswerFromToolControl(finalAnswer) {
|
|
7643
|
-
return
|
|
7557
|
+
return readNonEmptyString4(finalAnswer);
|
|
7644
7558
|
}
|
|
7645
7559
|
|
|
7646
7560
|
// src/runtime-kernel/graph-engine/nodes/toolNode.helpers.ts
|
|
@@ -7896,7 +7810,7 @@ function buildErrorLocalState(params) {
|
|
|
7896
7810
|
}
|
|
7897
7811
|
|
|
7898
7812
|
// src/runtime-kernel/tools/argNormalizer.ts
|
|
7899
|
-
var
|
|
7813
|
+
var logger7 = new Logger("ToolArgNormalizer");
|
|
7900
7814
|
function isRecord10(v) {
|
|
7901
7815
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
7902
7816
|
}
|
|
@@ -7916,7 +7830,7 @@ function joinPath(basePath, segment) {
|
|
|
7916
7830
|
function logJsonEncodedNormalization(expectedType, options) {
|
|
7917
7831
|
const toolPrefix = options.toolName ? `${options.toolName}.` : "";
|
|
7918
7832
|
const path = options.path ?? "<root>";
|
|
7919
|
-
|
|
7833
|
+
logger7.warn("normalized JSON-encoded tool argument", {
|
|
7920
7834
|
expectedType,
|
|
7921
7835
|
path: `${toolPrefix}${path}`
|
|
7922
7836
|
});
|
|
@@ -8212,7 +8126,7 @@ function ensureToolContextRuntimeCapability(params) {
|
|
|
8212
8126
|
}
|
|
8213
8127
|
|
|
8214
8128
|
// src/runtime-kernel/graph-engine/nodes/toolNode.eventBridge.ts
|
|
8215
|
-
var
|
|
8129
|
+
var logger8 = new Logger("ToolNode");
|
|
8216
8130
|
var ToolNodeEventBridge = class {
|
|
8217
8131
|
constructor(deps) {
|
|
8218
8132
|
this.deps = deps;
|
|
@@ -8234,7 +8148,7 @@ var ToolNodeEventBridge = class {
|
|
|
8234
8148
|
status,
|
|
8235
8149
|
payload: { ...payload }
|
|
8236
8150
|
};
|
|
8237
|
-
|
|
8151
|
+
logger8.info("[ToolNode] \u53D1\u51FA tool_process \u4E8B\u4EF6", {
|
|
8238
8152
|
phase,
|
|
8239
8153
|
status,
|
|
8240
8154
|
toolName: this.deps.toolName,
|
|
@@ -8274,7 +8188,7 @@ var ToolNodeEventBridge = class {
|
|
|
8274
8188
|
const answerId = generateAnswerSegmentId();
|
|
8275
8189
|
const id = answerId;
|
|
8276
8190
|
const timestamp = Date.now();
|
|
8277
|
-
|
|
8191
|
+
logger8.info("[ToolNode] \u5DE5\u5177\u8F93\u51FA\u6620\u5C04\u4E3A final_answer", {
|
|
8278
8192
|
sourceToolName: params.sourceToolName,
|
|
8279
8193
|
toolCallId: this.deps.toolCallId,
|
|
8280
8194
|
conversationId: this.deps.conversationId,
|
|
@@ -8332,7 +8246,7 @@ var ToolNodeEventBridge = class {
|
|
|
8332
8246
|
};
|
|
8333
8247
|
|
|
8334
8248
|
// src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
|
|
8335
|
-
var
|
|
8249
|
+
var logger9 = new Logger("ToolNode");
|
|
8336
8250
|
function parseToolArgs(call) {
|
|
8337
8251
|
const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
|
|
8338
8252
|
if (!rawArguments.trim()) {
|
|
@@ -8352,7 +8266,7 @@ function parseToolArgs(call) {
|
|
|
8352
8266
|
return { ok: true, value: parsed };
|
|
8353
8267
|
} catch (error) {
|
|
8354
8268
|
const reason = error instanceof Error ? error.message : "Unknown JSON parse error";
|
|
8355
|
-
|
|
8269
|
+
logger9.warn("failed to parse tool arguments", { error });
|
|
8356
8270
|
return {
|
|
8357
8271
|
ok: false,
|
|
8358
8272
|
error: `Tool arguments are not valid JSON: ${reason}`
|
|
@@ -8746,7 +8660,7 @@ async function claimPendingUserInputs(state, result) {
|
|
|
8746
8660
|
}
|
|
8747
8661
|
|
|
8748
8662
|
// src/runtime-kernel/graph-engine/nodes/toolNode.ts
|
|
8749
|
-
var
|
|
8663
|
+
var logger10 = new Logger("ToolNode");
|
|
8750
8664
|
function isAbortSignal(value) {
|
|
8751
8665
|
return value !== null && typeof value === "object" && "aborted" in value;
|
|
8752
8666
|
}
|
|
@@ -8959,7 +8873,7 @@ var ToolNode = class {
|
|
|
8959
8873
|
throw abortError;
|
|
8960
8874
|
}
|
|
8961
8875
|
const prepared = prepareToolNodeContext(state);
|
|
8962
|
-
|
|
8876
|
+
logger10.info("[ToolNode] \u5F00\u59CB\u6267\u884C\u5DE5\u5177\u8282\u70B9", {
|
|
8963
8877
|
conversationId: prepared.conversationId,
|
|
8964
8878
|
turnId: prepared.turnId,
|
|
8965
8879
|
pendingCallCount: calls.length
|
|
@@ -8974,7 +8888,7 @@ var ToolNode = class {
|
|
|
8974
8888
|
toolCatalog: this.toolRuntime
|
|
8975
8889
|
});
|
|
8976
8890
|
if (!execution) {
|
|
8977
|
-
|
|
8891
|
+
logger10.warn("no tool name found in call");
|
|
8978
8892
|
return { kind: "yield", events: [] };
|
|
8979
8893
|
}
|
|
8980
8894
|
if (typeof execution.protocolError === "string") {
|
|
@@ -9014,7 +8928,7 @@ var ToolNode = class {
|
|
|
9014
8928
|
call,
|
|
9015
8929
|
context: prepared.toolContext,
|
|
9016
8930
|
abortGraceMs: this.abortGraceMs,
|
|
9017
|
-
onAbandon: () =>
|
|
8931
|
+
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", {
|
|
9018
8932
|
toolName: execution.toolName,
|
|
9019
8933
|
toolCallId: execution.toolCallId,
|
|
9020
8934
|
conversationId: prepared.conversationId,
|
|
@@ -9184,7 +9098,7 @@ var ToolNode = class {
|
|
|
9184
9098
|
runtimeEvents: context.bridge.getRuntimeEvents()
|
|
9185
9099
|
});
|
|
9186
9100
|
if (control?.terminateRun) {
|
|
9187
|
-
|
|
9101
|
+
logger10.info("[ToolNode] \u6536\u5230 control.terminateRun\uFF0C\u6267\u884C\u5B8C\u5DE5\u5177\u540E\u76F4\u63A5 yield \u7ED3\u675F\u672C\u8F6E run", {
|
|
9188
9102
|
toolName: context.toolName,
|
|
9189
9103
|
toolCallId: context.toolCallId,
|
|
9190
9104
|
conversationId: context.conversationId,
|
|
@@ -9193,7 +9107,7 @@ var ToolNode = class {
|
|
|
9193
9107
|
return { kind: "yield", events: context.bridge.getRuntimeEvents() };
|
|
9194
9108
|
}
|
|
9195
9109
|
if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
|
|
9196
|
-
|
|
9110
|
+
logger10.info("[ToolNode] \u5DE5\u5177\u6279\u6B21\u5DF2\u7ED3\u7B97\uFF0C\u6309 Host \u7B56\u7565\u76F4\u63A5 yield", {
|
|
9197
9111
|
toolName: context.toolName,
|
|
9198
9112
|
toolCallId: context.toolCallId,
|
|
9199
9113
|
conversationId: context.conversationId,
|
|
@@ -9640,6 +9554,8 @@ var executor = z.object({
|
|
|
9640
9554
|
lastStepsHintThreshold: counter.optional(),
|
|
9641
9555
|
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
9642
9556
|
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
9557
|
+
// 已删除字段:0.45 及更早的 checkpoint 可能带 lastSuccessfulLlmModelId,0.46 及更早的可能带云端额度兜底留下的
|
|
9558
|
+
// runLockedModelId;照常接受,读入时丢弃(兜底已移除,恢复后按请求的模型继续)。
|
|
9643
9559
|
runLockedModelId: z.string().optional(),
|
|
9644
9560
|
lastSuccessfulLlmModelId: z.string().optional(),
|
|
9645
9561
|
llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
|
|
@@ -9650,7 +9566,7 @@ var executor = z.object({
|
|
|
9650
9566
|
committedCount: counter,
|
|
9651
9567
|
lastCommittedFingerprint: z.string().optional()
|
|
9652
9568
|
}).strict().optional()
|
|
9653
|
-
}).strict();
|
|
9569
|
+
}).strict().transform(({ lastSuccessfulLlmModelId: _retired, runLockedModelId: _retiredLock, ...state }) => state);
|
|
9654
9570
|
var checkpoint = z.object({
|
|
9655
9571
|
nodeId: z.string().min(1),
|
|
9656
9572
|
schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|
|
@@ -9712,7 +9628,7 @@ __export(execution_exports, {
|
|
|
9712
9628
|
});
|
|
9713
9629
|
|
|
9714
9630
|
// src/runtime-kernel/execution/event-bus.ts
|
|
9715
|
-
var
|
|
9631
|
+
var logger11 = new Logger("EventBus");
|
|
9716
9632
|
var TypedEventEmitter = class {
|
|
9717
9633
|
listeners = /* @__PURE__ */ new Map();
|
|
9718
9634
|
maxListeners = 10;
|
|
@@ -9720,7 +9636,7 @@ var TypedEventEmitter = class {
|
|
|
9720
9636
|
const listeners = this.getListeners(event);
|
|
9721
9637
|
listeners.add(listener);
|
|
9722
9638
|
if (listeners.size > this.maxListeners) {
|
|
9723
|
-
|
|
9639
|
+
logger11.warn("EventBus listener count exceeds configured max", {
|
|
9724
9640
|
event: String(event),
|
|
9725
9641
|
count: listeners.size,
|
|
9726
9642
|
maxListeners: this.maxListeners
|
|
@@ -9780,7 +9696,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9780
9696
|
super();
|
|
9781
9697
|
this.executionId = executionId;
|
|
9782
9698
|
this.setMaxListeners(30);
|
|
9783
|
-
|
|
9699
|
+
logger11.info(`EventBus created for execution ${this.executionId}`);
|
|
9784
9700
|
}
|
|
9785
9701
|
/**
|
|
9786
9702
|
* 发布一个事件到总线
|
|
@@ -9789,7 +9705,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9789
9705
|
publish(envelope) {
|
|
9790
9706
|
if (envelope.trace.execution_id !== this.executionId) {
|
|
9791
9707
|
const error = new Error("EventEnvelope execution_id does not match EventBus instance.");
|
|
9792
|
-
|
|
9708
|
+
logger11.error("Mismatched execution_id", {
|
|
9793
9709
|
busExecutionId: this.executionId,
|
|
9794
9710
|
eventExecutionId: envelope.trace.execution_id,
|
|
9795
9711
|
eventSeq: envelope.seq
|
|
@@ -9801,7 +9717,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9801
9717
|
const error = new Error(
|
|
9802
9718
|
"EventBus only accepts RuntimeEvent with formal run routing identity."
|
|
9803
9719
|
);
|
|
9804
|
-
|
|
9720
|
+
logger11.error("RuntimeEvent is missing formal run routing identity", {
|
|
9805
9721
|
executionId: this.executionId,
|
|
9806
9722
|
eventId: envelope.payload.id,
|
|
9807
9723
|
eventType: envelope.payload.type
|
|
@@ -9815,14 +9731,14 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9815
9731
|
* 关闭总线,清理所有监听器
|
|
9816
9732
|
*/
|
|
9817
9733
|
close() {
|
|
9818
|
-
|
|
9734
|
+
logger11.info(`Closing EventBus for execution ${this.executionId}`);
|
|
9819
9735
|
this.emit("close");
|
|
9820
9736
|
this.removeAllListeners();
|
|
9821
9737
|
}
|
|
9822
9738
|
};
|
|
9823
9739
|
|
|
9824
9740
|
// src/runtime-kernel/execution/sequencer.ts
|
|
9825
|
-
var
|
|
9741
|
+
var logger12 = new Logger("EventSequencer");
|
|
9826
9742
|
var EventSequencer = class {
|
|
9827
9743
|
executionId;
|
|
9828
9744
|
traceId;
|
|
@@ -9830,7 +9746,7 @@ var EventSequencer = class {
|
|
|
9830
9746
|
constructor(conversationId, traceId) {
|
|
9831
9747
|
this.executionId = generateExecutionId();
|
|
9832
9748
|
this.traceId = traceId || generateTraceId();
|
|
9833
|
-
|
|
9749
|
+
logger12.info(`EventSequencer created for conversation ${conversationId}`, {
|
|
9834
9750
|
executionId: this.executionId,
|
|
9835
9751
|
traceId: this.traceId
|
|
9836
9752
|
});
|
|
@@ -10643,7 +10559,7 @@ var ThoughtStreamSegmenter = class {
|
|
|
10643
10559
|
};
|
|
10644
10560
|
|
|
10645
10561
|
// src/runtime-kernel/llm/streaming-adapter.ts
|
|
10646
|
-
var
|
|
10562
|
+
var logger13 = new Logger("LlmCaller");
|
|
10647
10563
|
var CanonicalInferenceFailureError = class extends Error {
|
|
10648
10564
|
errorCode;
|
|
10649
10565
|
recoverable;
|
|
@@ -10867,7 +10783,7 @@ async function callLlmStream(params) {
|
|
|
10867
10783
|
} catch (error) {
|
|
10868
10784
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
10869
10785
|
if (normalized.name === "AbortError") {
|
|
10870
|
-
|
|
10786
|
+
logger13.info("Canonical inference \u6536\u5230\u53D6\u6D88\u7EC8\u6001\uFF0C\u4E0D\u53D1\u5E03\u666E\u901A error event", { modelId });
|
|
10871
10787
|
throw normalized;
|
|
10872
10788
|
}
|
|
10873
10789
|
const classification = ErrorClassifier.classify(normalized, {
|
|
@@ -10943,7 +10859,7 @@ var LlmRetryEpisode = class {
|
|
|
10943
10859
|
};
|
|
10944
10860
|
|
|
10945
10861
|
// src/runtime-kernel/llm/retry-fallback-routing.ts
|
|
10946
|
-
var
|
|
10862
|
+
var logger14 = new Logger("LlmCaller");
|
|
10947
10863
|
function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement, fallbackObserver, error, evaluateFallbackPromptCapacity2) {
|
|
10948
10864
|
deps.modelCatalog.getModelById(activeModelId);
|
|
10949
10865
|
const policyDecision = deps.policyEngine.decideOnError(error, {
|
|
@@ -10973,81 +10889,16 @@ function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement
|
|
|
10973
10889
|
reason: "no_eligible_fallback_candidate",
|
|
10974
10890
|
requiredPlacements: requirement.placements
|
|
10975
10891
|
});
|
|
10976
|
-
|
|
10892
|
+
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");
|
|
10977
10893
|
return null;
|
|
10978
10894
|
}
|
|
10979
|
-
|
|
10895
|
+
logger14.warn("Policy \u5207\u6362\u6A21\u578B\u7EE7\u7EED", {
|
|
10980
10896
|
reason: policyDecision.reason,
|
|
10981
10897
|
activeModelId,
|
|
10982
10898
|
fallbackModelId
|
|
10983
10899
|
});
|
|
10984
10900
|
return fallbackModelId;
|
|
10985
10901
|
}
|
|
10986
|
-
function tryCloudQuotaFallback({
|
|
10987
|
-
deps,
|
|
10988
|
-
activeModelId,
|
|
10989
|
-
options,
|
|
10990
|
-
excludedModelIds,
|
|
10991
|
-
requirement,
|
|
10992
|
-
error,
|
|
10993
|
-
fallbackObserver,
|
|
10994
|
-
evaluateFallbackPromptCapacity: evaluateFallbackPromptCapacity2
|
|
10995
|
-
}) {
|
|
10996
|
-
const fallbackModelId = options.cloud_quota_fallback_model_id;
|
|
10997
|
-
if (!fallbackModelId || !ErrorClassifier.isCloudQuotaError(error) || excludedModelIds.has(fallbackModelId)) {
|
|
10998
|
-
return null;
|
|
10999
|
-
}
|
|
11000
|
-
const fallbackConfig = deps.modelCatalog.getModelById(fallbackModelId);
|
|
11001
|
-
if (!fallbackConfig?.api_key) {
|
|
11002
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11003
|
-
fromModelId: activeModelId,
|
|
11004
|
-
candidateModelId: fallbackModelId,
|
|
11005
|
-
policy: "cloud-quota",
|
|
11006
|
-
reason: "fallback_model_unavailable",
|
|
11007
|
-
requiredPlacements: requirement.placements
|
|
11008
|
-
});
|
|
11009
|
-
logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u53EF\u7528\uFF08\u672A\u6CE8\u518C\u6216\u7F3A\u5C11 API Key\uFF09", { fallbackModelId });
|
|
11010
|
-
return null;
|
|
11011
|
-
}
|
|
11012
|
-
const compatibility = evaluateModelInputCompatibility(fallbackConfig, requirement);
|
|
11013
|
-
if (!compatibility.compatible) {
|
|
11014
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11015
|
-
fromModelId: activeModelId,
|
|
11016
|
-
candidateModelId: fallbackModelId,
|
|
11017
|
-
policy: "cloud-quota",
|
|
11018
|
-
reason: compatibility.reason,
|
|
11019
|
-
requiredPlacements: requirement.placements
|
|
11020
|
-
});
|
|
11021
|
-
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", {
|
|
11022
|
-
fallbackModelId,
|
|
11023
|
-
requiredPlacements: requirement.placements,
|
|
11024
|
-
reason: compatibility.reason
|
|
11025
|
-
});
|
|
11026
|
-
return null;
|
|
11027
|
-
}
|
|
11028
|
-
const capacityAdmission = evaluateFallbackPromptCapacity2?.(fallbackModelId);
|
|
11029
|
-
if (capacityAdmission && !capacityAdmission.admitted) {
|
|
11030
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11031
|
-
fromModelId: activeModelId,
|
|
11032
|
-
candidateModelId: fallbackModelId,
|
|
11033
|
-
policy: "cloud-quota",
|
|
11034
|
-
reason: capacityAdmission.reason,
|
|
11035
|
-
requiredPlacements: requirement.placements
|
|
11036
|
-
});
|
|
11037
|
-
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", {
|
|
11038
|
-
fallbackModelId,
|
|
11039
|
-
reason: capacityAdmission.reason
|
|
11040
|
-
});
|
|
11041
|
-
return null;
|
|
11042
|
-
}
|
|
11043
|
-
logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\uFF08run \u5185\u7EED\u8DD1\uFF09", {
|
|
11044
|
-
activeModelId,
|
|
11045
|
-
fallbackModelId,
|
|
11046
|
-
reason: error.message
|
|
11047
|
-
});
|
|
11048
|
-
fallbackObserver?.onCloudQuotaFallbackApplied?.(fallbackModelId);
|
|
11049
|
-
return fallbackModelId;
|
|
11050
|
-
}
|
|
11051
10902
|
|
|
11052
10903
|
// src/runtime-kernel/llm/usage-telemetry.ts
|
|
11053
10904
|
async function callPlainCompletion(inferencePort, modelId, messages, options = {}, signal, traceId) {
|
|
@@ -11150,7 +11001,7 @@ async function runLlmInputPreflight(params) {
|
|
|
11150
11001
|
}
|
|
11151
11002
|
|
|
11152
11003
|
// src/runtime-kernel/llm/retry-fallback.ts
|
|
11153
|
-
var
|
|
11004
|
+
var logger15 = new Logger("LlmCaller");
|
|
11154
11005
|
async function callWithRetryFallback(params) {
|
|
11155
11006
|
const {
|
|
11156
11007
|
deps,
|
|
@@ -11178,11 +11029,9 @@ async function callWithRetryFallback(params) {
|
|
|
11178
11029
|
const retryEpisode = new LlmRetryEpisode(traceId, eventHandler);
|
|
11179
11030
|
let previousAttemptTracker;
|
|
11180
11031
|
if (!clientRetryEnabled) {
|
|
11181
|
-
|
|
11182
|
-
logger16.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
|
|
11032
|
+
logger15.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
|
|
11183
11033
|
modelId,
|
|
11184
|
-
|
|
11185
|
-
reason: options.retry_policy === "none" ? "options.retry_policy=none" : "model config (cloud billing or enable_client_retry=false)"
|
|
11034
|
+
reason: options.retry_policy === "none" ? "options.retry_policy=none" : "model config enable_client_retry=false"
|
|
11186
11035
|
});
|
|
11187
11036
|
}
|
|
11188
11037
|
try {
|
|
@@ -11218,7 +11067,7 @@ async function callWithRetryFallback(params) {
|
|
|
11218
11067
|
}) : void 0;
|
|
11219
11068
|
try {
|
|
11220
11069
|
if (isRetry) {
|
|
11221
|
-
|
|
11070
|
+
logger15.info("LLM \u8C03\u7528\u91CD\u8BD5", { attempt, configuredMaxRetries });
|
|
11222
11071
|
}
|
|
11223
11072
|
actualAttempts++;
|
|
11224
11073
|
retryEpisode.retrying(actualAttempts);
|
|
@@ -11247,7 +11096,7 @@ async function callWithRetryFallback(params) {
|
|
|
11247
11096
|
if (deps.retryConfig.enableEmptyResponseRetry && !responseContent?.trim() && !toolCallsFromLLM?.length) {
|
|
11248
11097
|
throw new Error("LLM\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94");
|
|
11249
11098
|
}
|
|
11250
|
-
|
|
11099
|
+
logger15.debug("LLM \u8C03\u7528\u6210\u529F", { attempts: actualAttempts, maxTotalAttempts });
|
|
11251
11100
|
if (attemptContextUsage) {
|
|
11252
11101
|
fallbackObserver?.onLlmAttemptSucceeded?.(activeModelId, attemptContextUsage);
|
|
11253
11102
|
} else {
|
|
@@ -11258,7 +11107,7 @@ async function callWithRetryFallback(params) {
|
|
|
11258
11107
|
} catch (error) {
|
|
11259
11108
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
11260
11109
|
if (lastError.name === "AbortError") {
|
|
11261
|
-
|
|
11110
|
+
logger15.info("LLM \u8C03\u7528\u5DF2\u53D6\u6D88\uFF0C\u4E0D\u8FDB\u5165 provider failure \u5206\u7C7B\u4E0E\u91CD\u8BD5\u6D41\u7A0B", {
|
|
11262
11111
|
attempt: attempt + 1,
|
|
11263
11112
|
actualAttempts,
|
|
11264
11113
|
maxTotalAttempts,
|
|
@@ -11277,7 +11126,7 @@ async function callWithRetryFallback(params) {
|
|
|
11277
11126
|
total_attempts: actualAttempts,
|
|
11278
11127
|
error_code: classification.errorCode
|
|
11279
11128
|
};
|
|
11280
|
-
|
|
11129
|
+
logger15.error("LLM \u8C03\u7528\u5931\u8D25", {
|
|
11281
11130
|
attempt: attempt + 1,
|
|
11282
11131
|
maxAttempts: currentMaxRetries + 1,
|
|
11283
11132
|
actualAttempts,
|
|
@@ -11286,7 +11135,7 @@ async function callWithRetryFallback(params) {
|
|
|
11286
11135
|
});
|
|
11287
11136
|
previousAttemptTracker = attemptTracker;
|
|
11288
11137
|
if (!hasLlmAttemptBudgetRemaining({ actualAttempts, maxTotalAttempts })) {
|
|
11289
|
-
|
|
11138
|
+
logger15.error("\u5DF2\u8FBE\u5230 LLM \u603B\u8C03\u7528\u6B21\u6570\u4E0A\u9650\uFF0C\u505C\u6B62\u91CD\u8BD5/\u5207\u6A21\u578B", {
|
|
11290
11139
|
actualAttempts,
|
|
11291
11140
|
maxTotalAttempts
|
|
11292
11141
|
});
|
|
@@ -11316,37 +11165,15 @@ async function callWithRetryFallback(params) {
|
|
|
11316
11165
|
attempt -= 1;
|
|
11317
11166
|
continue;
|
|
11318
11167
|
}
|
|
11319
|
-
const quotaFallbackModelId = tryCloudQuotaFallback({
|
|
11320
|
-
deps,
|
|
11321
|
-
activeModelId,
|
|
11322
|
-
options,
|
|
11323
|
-
excludedModelIds,
|
|
11324
|
-
requirement,
|
|
11325
|
-
error: lastError,
|
|
11326
|
-
fallbackObserver,
|
|
11327
|
-
evaluateFallbackPromptCapacity: invocationContext?.evaluateFallbackPromptCapacity
|
|
11328
|
-
});
|
|
11329
|
-
if (quotaFallbackModelId) {
|
|
11330
|
-
fallbackObserver?.onModelFallbackApplied?.({
|
|
11331
|
-
fromModelId: activeModelId,
|
|
11332
|
-
toModelId: quotaFallbackModelId,
|
|
11333
|
-
reason: lastError.message,
|
|
11334
|
-
policy: "cloud-quota"
|
|
11335
|
-
});
|
|
11336
|
-
activeModelId = quotaFallbackModelId;
|
|
11337
|
-
excludedModelIds.add(quotaFallbackModelId);
|
|
11338
|
-
attempt -= 1;
|
|
11339
|
-
continue;
|
|
11340
|
-
}
|
|
11341
11168
|
}
|
|
11342
11169
|
if (classification.category === "non_retryable" /* NON_RETRYABLE */) {
|
|
11343
|
-
|
|
11170
|
+
logger15.error("\u9519\u8BEF\u4E0D\u53EF\u91CD\u8BD5\uFF0C\u76F4\u63A5\u5931\u8D25", { reason: classification.reason });
|
|
11344
11171
|
retryEpisode.finish("failed", failedRetryState);
|
|
11345
11172
|
emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
|
|
11346
11173
|
throw lastError;
|
|
11347
11174
|
}
|
|
11348
11175
|
if (attempt >= configuredMaxRetries || categoryRetries[category] >= currentMaxRetries) {
|
|
11349
|
-
|
|
11176
|
+
logger15.error("\u5DF2\u8FBE\u5230\u6700\u5927\u91CD\u8BD5\u6B21\u6570\uFF0C\u653E\u5F03\u91CD\u8BD5", { maxRetries: currentMaxRetries });
|
|
11350
11177
|
retryEpisode.finish("exhausted", failedRetryState);
|
|
11351
11178
|
emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
|
|
11352
11179
|
throw lastError;
|
|
@@ -11358,9 +11185,9 @@ async function callWithRetryFallback(params) {
|
|
|
11358
11185
|
6e4
|
|
11359
11186
|
);
|
|
11360
11187
|
if (classification.category === "rate_limit" /* RATE_LIMIT */) {
|
|
11361
|
-
|
|
11188
|
+
logger15.warn("\u901F\u7387\u9650\u5236\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
|
|
11362
11189
|
} else if (classification.category === "retryable" /* RETRYABLE */) {
|
|
11363
|
-
|
|
11190
|
+
logger15.warn("\u53EF\u91CD\u8BD5\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
|
|
11364
11191
|
}
|
|
11365
11192
|
throwIfAborted(signal, "\u5EF6\u8FDF\u7B49\u5F85\u524D\u68C0\u6D4B\u5230\u53D6\u6D88\u4FE1\u53F7\uFF0C\u505C\u6B62\u91CD\u8BD5");
|
|
11366
11193
|
categoryRetries[category] += 1;
|
|
@@ -11397,16 +11224,11 @@ function waitForRetry(delayMs, signal) {
|
|
|
11397
11224
|
}
|
|
11398
11225
|
function isClientRetryEnabledForModel(modelCatalog, modelId, options) {
|
|
11399
11226
|
if (options.retry_policy === "none") return false;
|
|
11400
|
-
|
|
11401
|
-
if (cfg?.billing_mode === "cloud") return false;
|
|
11402
|
-
if (options.retry_policy === "client") return true;
|
|
11403
|
-
if (!cfg) return true;
|
|
11404
|
-
if (cfg.enable_client_retry === false) return false;
|
|
11405
|
-
return true;
|
|
11227
|
+
return modelCatalog.getModelById(modelId)?.enable_client_retry !== false;
|
|
11406
11228
|
}
|
|
11407
11229
|
function throwIfAborted(signal, message) {
|
|
11408
11230
|
if (!signal?.aborted) return;
|
|
11409
|
-
|
|
11231
|
+
logger15.info(message);
|
|
11410
11232
|
const reason = signal.reason;
|
|
11411
11233
|
if (reason instanceof Error && reason.name === "AbortError") throw reason;
|
|
11412
11234
|
const reasonText = typeof reason === "string" && reason.trim().length > 0 ? reason : "stream_interrupted";
|
|
@@ -12089,7 +11911,7 @@ function runMetaFromRecord(record) {
|
|
|
12089
11911
|
}
|
|
12090
11912
|
|
|
12091
11913
|
// src/runtime-kernel/run-supervisor/functions/awaitingUserWatcher.ts
|
|
12092
|
-
var
|
|
11914
|
+
var logger17 = new Logger("RunSupervisorAwaitingUserWatcher");
|
|
12093
11915
|
function isRecord16(value) {
|
|
12094
11916
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12095
11917
|
}
|
|
@@ -12134,7 +11956,7 @@ function createAwaitingUserWatcher(options) {
|
|
|
12134
11956
|
resumeToken: event.resume_token
|
|
12135
11957
|
}
|
|
12136
11958
|
}).catch((error) => {
|
|
12137
|
-
|
|
11959
|
+
logger17.warn("failed to mark awaiting_user from requires_user_interaction", { error });
|
|
12138
11960
|
});
|
|
12139
11961
|
};
|
|
12140
11962
|
const dispose = () => {
|