@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.cjs
CHANGED
|
@@ -2221,18 +2221,6 @@ var ErrorClassifier = class {
|
|
|
2221
2221
|
});
|
|
2222
2222
|
}
|
|
2223
2223
|
}
|
|
2224
|
-
const quotaPatterns = ["\u5DF2\u8FBE\u4E0A\u9650", "\u514D\u8D39\u671F\u5DF2\u7ED3\u675F"];
|
|
2225
|
-
for (const pattern of quotaPatterns) {
|
|
2226
|
-
if (errorMessage.includes(pattern)) {
|
|
2227
|
-
logClassification(context, "\u68C0\u6D4B\u5230\u4E91\u7AEF\u989D\u5EA6\u9650\u5236\uFF0C\u4E0D\u91CD\u8BD5", { matchedPattern: pattern });
|
|
2228
|
-
return createClassification("non_retryable" /* NON_RETRYABLE */, `\u4E91\u7AEF\u989D\u5EA6\u9650\u5236: ${pattern}`, null, {
|
|
2229
|
-
errorCode: ENGINE_ERROR_CODES.LLM_PROVIDER_DOWN,
|
|
2230
|
-
recoverable: false,
|
|
2231
|
-
hint: "check_billing_or_provider_status",
|
|
2232
|
-
metadata: { matchedPattern: pattern }
|
|
2233
|
-
});
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
2224
|
const authPatterns = [
|
|
2237
2225
|
{ pattern: "unauthorized", code: "401" },
|
|
2238
2226
|
{ pattern: "forbidden", code: "403" },
|
|
@@ -2487,17 +2475,6 @@ var ErrorClassifier = class {
|
|
|
2487
2475
|
}
|
|
2488
2476
|
return Math.max(baseDelay, classification.suggestedDelay ?? 0);
|
|
2489
2477
|
}
|
|
2490
|
-
static isCloudQuotaError(error) {
|
|
2491
|
-
const msg = (error.message || "").toLowerCase();
|
|
2492
|
-
const patterns = [
|
|
2493
|
-
"\u989D\u5EA6\u4E0A\u9650",
|
|
2494
|
-
"\u5DF2\u8FBE\u4E0A\u9650",
|
|
2495
|
-
"\u514D\u8D39\u671F\u5DF2\u7ED3\u675F",
|
|
2496
|
-
"\u8BE5\u6A21\u578B\u6682\u4E0D\u53EF\u7528",
|
|
2497
|
-
"cloud_quota_exhausted"
|
|
2498
|
-
];
|
|
2499
|
-
return patterns.some((pattern) => msg.includes(pattern));
|
|
2500
|
-
}
|
|
2501
2478
|
};
|
|
2502
2479
|
|
|
2503
2480
|
// src/shared/engineErrorEvent.ts
|
|
@@ -3981,8 +3958,8 @@ var TokenCalculator = class {
|
|
|
3981
3958
|
return;
|
|
3982
3959
|
}
|
|
3983
3960
|
this.failedEncodingWarnings.add(requestedEncoding);
|
|
3984
|
-
const
|
|
3985
|
-
|
|
3961
|
+
const logger18 = new Logger("TokenCalculator");
|
|
3962
|
+
logger18.warn("tiktoken encoding unavailable, falling back to avgCharsPerToken estimator", {
|
|
3986
3963
|
requestedEncoding,
|
|
3987
3964
|
error
|
|
3988
3965
|
});
|
|
@@ -4074,49 +4051,6 @@ var llmTelemetryMiddleware = async (ctx, stage, next) => {
|
|
|
4074
4051
|
});
|
|
4075
4052
|
};
|
|
4076
4053
|
|
|
4077
|
-
// src/runtime-kernel/graph-engine/functions/runModelLock.ts
|
|
4078
|
-
function readNonEmptyString4(value) {
|
|
4079
|
-
if (typeof value !== "string") return void 0;
|
|
4080
|
-
const trimmed = value.trim();
|
|
4081
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
4082
|
-
}
|
|
4083
|
-
function decideRunModelLockPatch(params) {
|
|
4084
|
-
if (params.stageId !== "execute_llm") {
|
|
4085
|
-
return { shouldLog: false };
|
|
4086
|
-
}
|
|
4087
|
-
const normalized = readNonEmptyString4(params.appliedFallbackModelId);
|
|
4088
|
-
if (!normalized) {
|
|
4089
|
-
return { shouldLog: false };
|
|
4090
|
-
}
|
|
4091
|
-
if (readNonEmptyString4(params.currentRunLockedModelId) === normalized) {
|
|
4092
|
-
return { shouldLog: false };
|
|
4093
|
-
}
|
|
4094
|
-
return {
|
|
4095
|
-
executorLocalPatch: { runLockedModelId: normalized },
|
|
4096
|
-
shouldLog: true
|
|
4097
|
-
};
|
|
4098
|
-
}
|
|
4099
|
-
|
|
4100
|
-
// src/runtime-kernel/graph-engine/tick-pipeline/middlewares/runModelLockMiddleware.ts
|
|
4101
|
-
var logger4 = new Logger("GraphAgentExecutor");
|
|
4102
|
-
var runModelLockMiddleware = async (ctx, stage, next) => {
|
|
4103
|
-
await next();
|
|
4104
|
-
const decision = decideRunModelLockPatch({
|
|
4105
|
-
stageId: stage.id,
|
|
4106
|
-
appliedFallbackModelId: ctx.cloudQuotaFallbackAppliedModelId,
|
|
4107
|
-
currentRunLockedModelId: ctx.executorLocalPatch?.runLockedModelId ?? ctx.executorLocal?.runLockedModelId
|
|
4108
|
-
});
|
|
4109
|
-
if (!decision.executorLocalPatch) {
|
|
4110
|
-
return;
|
|
4111
|
-
}
|
|
4112
|
-
if (decision.shouldLog) {
|
|
4113
|
-
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}`);
|
|
4114
|
-
}
|
|
4115
|
-
return {
|
|
4116
|
-
executorLocalPatch: decision.executorLocalPatch
|
|
4117
|
-
};
|
|
4118
|
-
};
|
|
4119
|
-
|
|
4120
4054
|
// src/runtime-kernel/graph-engine/tick-pipeline/runTickPipeline.ts
|
|
4121
4055
|
var tickPipelineContextKeys = [
|
|
4122
4056
|
"input",
|
|
@@ -4152,7 +4086,6 @@ var tickPipelineContextKeys = [
|
|
|
4152
4086
|
"decision",
|
|
4153
4087
|
"systemReminderHitRuleIds",
|
|
4154
4088
|
"contextTrace",
|
|
4155
|
-
"cloudQuotaFallbackAppliedModelId",
|
|
4156
4089
|
"modelFallbackAudit",
|
|
4157
4090
|
"telemetry",
|
|
4158
4091
|
"audit",
|
|
@@ -4491,7 +4424,7 @@ ${normalized}
|
|
|
4491
4424
|
}
|
|
4492
4425
|
|
|
4493
4426
|
// src/runtime-kernel/system-reminder/apply.ts
|
|
4494
|
-
var
|
|
4427
|
+
var logger4 = new Logger("SystemReminder");
|
|
4495
4428
|
var readString2 = (v) => {
|
|
4496
4429
|
if (typeof v !== "string") return void 0;
|
|
4497
4430
|
const s = v;
|
|
@@ -4554,7 +4487,7 @@ function applySystemReminders(params) {
|
|
|
4554
4487
|
} catch {
|
|
4555
4488
|
}
|
|
4556
4489
|
}
|
|
4557
|
-
|
|
4490
|
+
logger4.info("SystemReminder \u5DF2\u6CE8\u5165\u5230 LLM \u8F93\u5165\u672B\u5C3E", {
|
|
4558
4491
|
ruleIds: injectedRuleIds.length > 0 ? injectedRuleIds : Array.from(seenRuleIds),
|
|
4559
4492
|
promptKey: ctx.request.promptKey,
|
|
4560
4493
|
executorLocal: {
|
|
@@ -5046,18 +4979,14 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5046
4979
|
"turnId"
|
|
5047
4980
|
],
|
|
5048
4981
|
writes: [
|
|
5049
|
-
"cloudQuotaFallbackAppliedModelId",
|
|
5050
4982
|
"modelFallbackAudit",
|
|
5051
4983
|
"llmCallStartedAt",
|
|
5052
4984
|
"llmResp",
|
|
5053
4985
|
"llmCallDurationMs",
|
|
5054
|
-
"executorLocalPatch",
|
|
5055
4986
|
"contextUsage"
|
|
5056
4987
|
],
|
|
5057
4988
|
async run(ctx) {
|
|
5058
|
-
let cloudQuotaFallbackAppliedModelId;
|
|
5059
4989
|
let modelFallbackAudit;
|
|
5060
|
-
let lastSuccessfulLlmModelId;
|
|
5061
4990
|
let contextUsage;
|
|
5062
4991
|
const modelFallbackRejections = [];
|
|
5063
4992
|
const promptBudget = ctx.promptBudget;
|
|
@@ -5075,11 +5004,7 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5075
5004
|
streamEventHandler,
|
|
5076
5005
|
ctx.signal,
|
|
5077
5006
|
{
|
|
5078
|
-
|
|
5079
|
-
cloudQuotaFallbackAppliedModelId = readNonEmptyString3(fallbackModelId);
|
|
5080
|
-
},
|
|
5081
|
-
onLlmAttemptSucceeded(activeModelId, attemptContextUsage) {
|
|
5082
|
-
lastSuccessfulLlmModelId = readNonEmptyString3(activeModelId);
|
|
5007
|
+
onLlmAttemptSucceeded(_activeModelId, attemptContextUsage) {
|
|
5083
5008
|
contextUsage = attemptContextUsage;
|
|
5084
5009
|
},
|
|
5085
5010
|
onModelFallbackApplied(info) {
|
|
@@ -5175,12 +5100,10 @@ function createExecuteLlmStage(dependencies) {
|
|
|
5175
5100
|
});
|
|
5176
5101
|
}
|
|
5177
5102
|
return {
|
|
5178
|
-
cloudQuotaFallbackAppliedModelId,
|
|
5179
5103
|
modelFallbackAudit,
|
|
5180
5104
|
llmCallStartedAt,
|
|
5181
5105
|
llmResp,
|
|
5182
5106
|
llmCallDurationMs,
|
|
5183
|
-
executorLocalPatch: lastSuccessfulLlmModelId ? { lastSuccessfulLlmModelId } : void 0,
|
|
5184
5107
|
contextUsage
|
|
5185
5108
|
};
|
|
5186
5109
|
}
|
|
@@ -6097,18 +6020,16 @@ function createPrepareCallStage(dependencies) {
|
|
|
6097
6020
|
"toolDefinitionTokens"
|
|
6098
6021
|
],
|
|
6099
6022
|
async run(ctx) {
|
|
6100
|
-
const
|
|
6101
|
-
const requestedModelId = lockedRunModelId ?? ctx.request.model_id;
|
|
6023
|
+
const requestedModelId = ctx.request.model_id;
|
|
6102
6024
|
const modelId = dependencies.modelResolver.resolveModelId(requestedModelId);
|
|
6103
6025
|
await emitAuditEnvelope(ctx.audit, {
|
|
6104
6026
|
action: "model.select",
|
|
6105
6027
|
actor: { kind: "system" },
|
|
6106
6028
|
decision: {
|
|
6107
6029
|
outcome: "recorded",
|
|
6108
|
-
reason:
|
|
6030
|
+
reason: requestedModelId ? "request model id" : "default model resolver",
|
|
6109
6031
|
metadata: {
|
|
6110
6032
|
requestedModelId,
|
|
6111
|
-
lockedRunModelId,
|
|
6112
6033
|
selectedModelId: modelId
|
|
6113
6034
|
}
|
|
6114
6035
|
},
|
|
@@ -6155,10 +6076,6 @@ function createPrepareCallStage(dependencies) {
|
|
|
6155
6076
|
if (ctx.executorLocal?.lockRequestedModelId === true) {
|
|
6156
6077
|
llmOptions.allow_model_fallback = false;
|
|
6157
6078
|
}
|
|
6158
|
-
const isRunContinuation = ctx.executorLocal?.llmInvocationKind === "continuation";
|
|
6159
|
-
if (dependencies.cloudQuotaFallbackModelId && modelConfig?.billing_mode === "cloud" && modelId !== dependencies.cloudQuotaFallbackModelId && isRunContinuation && ctx.executorLocal?.lockRequestedModelId !== true) {
|
|
6160
|
-
llmOptions.cloud_quota_fallback_model_id = dependencies.cloudQuotaFallbackModelId;
|
|
6161
|
-
}
|
|
6162
6079
|
const effectiveEffort = resolveEffectiveEffort(
|
|
6163
6080
|
ctx.request.reasoning_effort,
|
|
6164
6081
|
modelConfig?.reasoning
|
|
@@ -6275,12 +6192,11 @@ function applyCalibration(rawLocalTotal, imageInputTokens, coefficient) {
|
|
|
6275
6192
|
}
|
|
6276
6193
|
|
|
6277
6194
|
// src/runtime-kernel/graph-engine/executor.ts
|
|
6278
|
-
var
|
|
6195
|
+
var logger5 = new Logger("GraphAgentExecutor");
|
|
6279
6196
|
var GraphAgentExecutor = class {
|
|
6280
6197
|
llmCaller;
|
|
6281
6198
|
toolRuntime;
|
|
6282
6199
|
contextBuilder;
|
|
6283
|
-
cloudQuotaFallbackModelId;
|
|
6284
6200
|
modelResolver;
|
|
6285
6201
|
modelCatalog;
|
|
6286
6202
|
telemetryPort;
|
|
@@ -6292,7 +6208,6 @@ var GraphAgentExecutor = class {
|
|
|
6292
6208
|
this.llmCaller = dependencies.llmCaller;
|
|
6293
6209
|
this.toolRuntime = dependencies.toolRuntime;
|
|
6294
6210
|
this.contextBuilder = dependencies.contextBuilder;
|
|
6295
|
-
this.cloudQuotaFallbackModelId = readNonEmptyString3(dependencies.cloudQuotaFallbackModelId);
|
|
6296
6211
|
this.modelCatalog = dependencies.modelCatalog ?? createEmptyModelCatalog();
|
|
6297
6212
|
this.modelResolver = dependencies.modelResolver ?? new ModelResolver({
|
|
6298
6213
|
modelCatalog: this.modelCatalog
|
|
@@ -6309,8 +6224,7 @@ var GraphAgentExecutor = class {
|
|
|
6309
6224
|
createPrepareCallStage({
|
|
6310
6225
|
modelResolver: this.modelResolver,
|
|
6311
6226
|
modelCatalog: this.modelCatalog,
|
|
6312
|
-
toolCatalog: this.toolRuntime
|
|
6313
|
-
cloudQuotaFallbackModelId: this.cloudQuotaFallbackModelId
|
|
6227
|
+
toolCatalog: this.toolRuntime
|
|
6314
6228
|
}),
|
|
6315
6229
|
createBuildContextStage({
|
|
6316
6230
|
contextBuilder: this.contextBuilder
|
|
@@ -6332,7 +6246,7 @@ var GraphAgentExecutor = class {
|
|
|
6332
6246
|
}),
|
|
6333
6247
|
createBuildDecisionStage()
|
|
6334
6248
|
];
|
|
6335
|
-
this.middlewares = [llmTelemetryMiddleware
|
|
6249
|
+
this.middlewares = [llmTelemetryMiddleware];
|
|
6336
6250
|
}
|
|
6337
6251
|
async tick(input, eventHandler) {
|
|
6338
6252
|
const ctx = {
|
|
@@ -6357,7 +6271,7 @@ var GraphAgentExecutor = class {
|
|
|
6357
6271
|
audit: this.auditPort,
|
|
6358
6272
|
tokenizer: this.tokenizer
|
|
6359
6273
|
};
|
|
6360
|
-
|
|
6274
|
+
logger5.info("[GraphAgentExecutor] tick \u8C03\u7528", {
|
|
6361
6275
|
stream: input.stream === true,
|
|
6362
6276
|
hasEventHandler: Boolean(eventHandler),
|
|
6363
6277
|
hasSummarizationCallbacks: Boolean(input.summarizationCallbacks)
|
|
@@ -7380,7 +7294,7 @@ var LlmNodeEventBridge = class {
|
|
|
7380
7294
|
};
|
|
7381
7295
|
|
|
7382
7296
|
// src/runtime-kernel/graph-engine/nodes/llmNode.ts
|
|
7383
|
-
var
|
|
7297
|
+
var logger6 = new Logger("LlmNode");
|
|
7384
7298
|
var LlmNode = class {
|
|
7385
7299
|
id = "llm";
|
|
7386
7300
|
reasoner;
|
|
@@ -7389,7 +7303,7 @@ var LlmNode = class {
|
|
|
7389
7303
|
}
|
|
7390
7304
|
async run(state) {
|
|
7391
7305
|
const local = state.local ?? {};
|
|
7392
|
-
|
|
7306
|
+
logger6.info("[LlmNode] \u5F00\u59CB\u6267\u884C LLM \u8282\u70B9", {
|
|
7393
7307
|
localKeys: Object.keys(local)
|
|
7394
7308
|
});
|
|
7395
7309
|
const graphLocal = readGraphAgentLocal(state.local);
|
|
@@ -7404,12 +7318,12 @@ var LlmNode = class {
|
|
|
7404
7318
|
signal,
|
|
7405
7319
|
history
|
|
7406
7320
|
} = graphLocal;
|
|
7407
|
-
|
|
7321
|
+
logger6.info("[LlmNode] \u5DF2\u52A0\u8F7D\u5386\u53F2\u4E8B\u4EF6", {
|
|
7408
7322
|
historyCount: history.length,
|
|
7409
7323
|
hasSummarizationCallbacks: Boolean(summarizationCallbacks)
|
|
7410
7324
|
});
|
|
7411
7325
|
if (!request) {
|
|
7412
|
-
|
|
7326
|
+
logger6.warn("Request object is missing, yielding.");
|
|
7413
7327
|
return { kind: "yield", events: [] };
|
|
7414
7328
|
}
|
|
7415
7329
|
const turnId = requireRuntimeIdentity(graphLocal.turnId, "turnId");
|
|
@@ -7502,12 +7416,12 @@ var LlmNode = class {
|
|
|
7502
7416
|
...nodeState.streamRuntimeEvents,
|
|
7503
7417
|
...contextUsageEvent ? [contextUsageEvent] : []
|
|
7504
7418
|
];
|
|
7505
|
-
|
|
7419
|
+
logger6.info("[LlmNode] \u5386\u53F2\u4E8B\u4EF6\u5DF2\u66F4\u65B0", {
|
|
7506
7420
|
previousCount: history.length,
|
|
7507
7421
|
nextCount: patch.history.length,
|
|
7508
7422
|
streamedEventCount: nodeState.streamRuntimeEvents.length
|
|
7509
7423
|
});
|
|
7510
|
-
|
|
7424
|
+
logger6.info("[LlmNode] \u6267\u884C\u5668\u51B3\u7B56\u5B8C\u6210", {
|
|
7511
7425
|
decisionKind: decision.kind,
|
|
7512
7426
|
emittedEventCount: combinedEvents.length
|
|
7513
7427
|
});
|
|
@@ -7529,7 +7443,7 @@ var LlmNode = class {
|
|
|
7529
7443
|
}
|
|
7530
7444
|
case "error": {
|
|
7531
7445
|
const { name, message, stack } = decision.error;
|
|
7532
|
-
|
|
7446
|
+
logger6.error("[LlmNode] Executor returned an error", { name, message, stack });
|
|
7533
7447
|
return { kind: "yield", events: combinedEvents };
|
|
7534
7448
|
}
|
|
7535
7449
|
default: {
|
|
@@ -7635,7 +7549,7 @@ async function resolveToolModelInput(input) {
|
|
|
7635
7549
|
}
|
|
7636
7550
|
|
|
7637
7551
|
// src/runtime-kernel/graph-engine/nodes/toolNode.finalAnswerProjector.ts
|
|
7638
|
-
function
|
|
7552
|
+
function readNonEmptyString4(value) {
|
|
7639
7553
|
if (typeof value !== "string") {
|
|
7640
7554
|
return void 0;
|
|
7641
7555
|
}
|
|
@@ -7643,7 +7557,7 @@ function readNonEmptyString5(value) {
|
|
|
7643
7557
|
return normalized.length > 0 ? normalized : void 0;
|
|
7644
7558
|
}
|
|
7645
7559
|
function resolveFinalAnswerFromToolControl(finalAnswer) {
|
|
7646
|
-
return
|
|
7560
|
+
return readNonEmptyString4(finalAnswer);
|
|
7647
7561
|
}
|
|
7648
7562
|
|
|
7649
7563
|
// src/runtime-kernel/graph-engine/nodes/toolNode.helpers.ts
|
|
@@ -7899,7 +7813,7 @@ function buildErrorLocalState(params) {
|
|
|
7899
7813
|
}
|
|
7900
7814
|
|
|
7901
7815
|
// src/runtime-kernel/tools/argNormalizer.ts
|
|
7902
|
-
var
|
|
7816
|
+
var logger7 = new Logger("ToolArgNormalizer");
|
|
7903
7817
|
function isRecord10(v) {
|
|
7904
7818
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
7905
7819
|
}
|
|
@@ -7919,7 +7833,7 @@ function joinPath(basePath, segment) {
|
|
|
7919
7833
|
function logJsonEncodedNormalization(expectedType, options) {
|
|
7920
7834
|
const toolPrefix = options.toolName ? `${options.toolName}.` : "";
|
|
7921
7835
|
const path = options.path ?? "<root>";
|
|
7922
|
-
|
|
7836
|
+
logger7.warn("normalized JSON-encoded tool argument", {
|
|
7923
7837
|
expectedType,
|
|
7924
7838
|
path: `${toolPrefix}${path}`
|
|
7925
7839
|
});
|
|
@@ -8215,7 +8129,7 @@ function ensureToolContextRuntimeCapability(params) {
|
|
|
8215
8129
|
}
|
|
8216
8130
|
|
|
8217
8131
|
// src/runtime-kernel/graph-engine/nodes/toolNode.eventBridge.ts
|
|
8218
|
-
var
|
|
8132
|
+
var logger8 = new Logger("ToolNode");
|
|
8219
8133
|
var ToolNodeEventBridge = class {
|
|
8220
8134
|
constructor(deps) {
|
|
8221
8135
|
this.deps = deps;
|
|
@@ -8237,7 +8151,7 @@ var ToolNodeEventBridge = class {
|
|
|
8237
8151
|
status,
|
|
8238
8152
|
payload: { ...payload }
|
|
8239
8153
|
};
|
|
8240
|
-
|
|
8154
|
+
logger8.info("[ToolNode] \u53D1\u51FA tool_process \u4E8B\u4EF6", {
|
|
8241
8155
|
phase,
|
|
8242
8156
|
status,
|
|
8243
8157
|
toolName: this.deps.toolName,
|
|
@@ -8277,7 +8191,7 @@ var ToolNodeEventBridge = class {
|
|
|
8277
8191
|
const answerId = generateAnswerSegmentId();
|
|
8278
8192
|
const id = answerId;
|
|
8279
8193
|
const timestamp = Date.now();
|
|
8280
|
-
|
|
8194
|
+
logger8.info("[ToolNode] \u5DE5\u5177\u8F93\u51FA\u6620\u5C04\u4E3A final_answer", {
|
|
8281
8195
|
sourceToolName: params.sourceToolName,
|
|
8282
8196
|
toolCallId: this.deps.toolCallId,
|
|
8283
8197
|
conversationId: this.deps.conversationId,
|
|
@@ -8335,7 +8249,7 @@ var ToolNodeEventBridge = class {
|
|
|
8335
8249
|
};
|
|
8336
8250
|
|
|
8337
8251
|
// src/runtime-kernel/graph-engine/nodes/toolNode.executionSetup.ts
|
|
8338
|
-
var
|
|
8252
|
+
var logger9 = new Logger("ToolNode");
|
|
8339
8253
|
function parseToolArgs(call) {
|
|
8340
8254
|
const rawArguments = typeof call.function?.arguments === "string" ? call.function.arguments : "";
|
|
8341
8255
|
if (!rawArguments.trim()) {
|
|
@@ -8355,7 +8269,7 @@ function parseToolArgs(call) {
|
|
|
8355
8269
|
return { ok: true, value: parsed };
|
|
8356
8270
|
} catch (error) {
|
|
8357
8271
|
const reason = error instanceof Error ? error.message : "Unknown JSON parse error";
|
|
8358
|
-
|
|
8272
|
+
logger9.warn("failed to parse tool arguments", { error });
|
|
8359
8273
|
return {
|
|
8360
8274
|
ok: false,
|
|
8361
8275
|
error: `Tool arguments are not valid JSON: ${reason}`
|
|
@@ -8749,7 +8663,7 @@ async function claimPendingUserInputs(state, result) {
|
|
|
8749
8663
|
}
|
|
8750
8664
|
|
|
8751
8665
|
// src/runtime-kernel/graph-engine/nodes/toolNode.ts
|
|
8752
|
-
var
|
|
8666
|
+
var logger10 = new Logger("ToolNode");
|
|
8753
8667
|
function isAbortSignal(value) {
|
|
8754
8668
|
return value !== null && typeof value === "object" && "aborted" in value;
|
|
8755
8669
|
}
|
|
@@ -8962,7 +8876,7 @@ var ToolNode = class {
|
|
|
8962
8876
|
throw abortError;
|
|
8963
8877
|
}
|
|
8964
8878
|
const prepared = prepareToolNodeContext(state);
|
|
8965
|
-
|
|
8879
|
+
logger10.info("[ToolNode] \u5F00\u59CB\u6267\u884C\u5DE5\u5177\u8282\u70B9", {
|
|
8966
8880
|
conversationId: prepared.conversationId,
|
|
8967
8881
|
turnId: prepared.turnId,
|
|
8968
8882
|
pendingCallCount: calls.length
|
|
@@ -8977,7 +8891,7 @@ var ToolNode = class {
|
|
|
8977
8891
|
toolCatalog: this.toolRuntime
|
|
8978
8892
|
});
|
|
8979
8893
|
if (!execution) {
|
|
8980
|
-
|
|
8894
|
+
logger10.warn("no tool name found in call");
|
|
8981
8895
|
return { kind: "yield", events: [] };
|
|
8982
8896
|
}
|
|
8983
8897
|
if (typeof execution.protocolError === "string") {
|
|
@@ -9017,7 +8931,7 @@ var ToolNode = class {
|
|
|
9017
8931
|
call,
|
|
9018
8932
|
context: prepared.toolContext,
|
|
9019
8933
|
abortGraceMs: this.abortGraceMs,
|
|
9020
|
-
onAbandon: () =>
|
|
8934
|
+
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", {
|
|
9021
8935
|
toolName: execution.toolName,
|
|
9022
8936
|
toolCallId: execution.toolCallId,
|
|
9023
8937
|
conversationId: prepared.conversationId,
|
|
@@ -9187,7 +9101,7 @@ var ToolNode = class {
|
|
|
9187
9101
|
runtimeEvents: context.bridge.getRuntimeEvents()
|
|
9188
9102
|
});
|
|
9189
9103
|
if (control?.terminateRun) {
|
|
9190
|
-
|
|
9104
|
+
logger10.info("[ToolNode] \u6536\u5230 control.terminateRun\uFF0C\u6267\u884C\u5B8C\u5DE5\u5177\u540E\u76F4\u63A5 yield \u7ED3\u675F\u672C\u8F6E run", {
|
|
9191
9105
|
toolName: context.toolName,
|
|
9192
9106
|
toolCallId: context.toolCallId,
|
|
9193
9107
|
conversationId: context.conversationId,
|
|
@@ -9196,7 +9110,7 @@ var ToolNode = class {
|
|
|
9196
9110
|
return { kind: "yield", events: context.bridge.getRuntimeEvents() };
|
|
9197
9111
|
}
|
|
9198
9112
|
if (remainingCalls.length === 0 && context.local.toolBatchCompletionMode === "yield_after_batch") {
|
|
9199
|
-
|
|
9113
|
+
logger10.info("[ToolNode] \u5DE5\u5177\u6279\u6B21\u5DF2\u7ED3\u7B97\uFF0C\u6309 Host \u7B56\u7565\u76F4\u63A5 yield", {
|
|
9200
9114
|
toolName: context.toolName,
|
|
9201
9115
|
toolCallId: context.toolCallId,
|
|
9202
9116
|
conversationId: context.conversationId,
|
|
@@ -9643,6 +9557,8 @@ var executor = zod.z.object({
|
|
|
9643
9557
|
lastStepsHintThreshold: counter.optional(),
|
|
9644
9558
|
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
9645
9559
|
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
9560
|
+
// 已删除字段:0.45 及更早的 checkpoint 可能带 lastSuccessfulLlmModelId,0.46 及更早的可能带云端额度兜底留下的
|
|
9561
|
+
// runLockedModelId;照常接受,读入时丢弃(兜底已移除,恢复后按请求的模型继续)。
|
|
9646
9562
|
runLockedModelId: zod.z.string().optional(),
|
|
9647
9563
|
lastSuccessfulLlmModelId: zod.z.string().optional(),
|
|
9648
9564
|
llmInvocationKind: zod.z.enum(["user_initiated", "continuation"]).optional(),
|
|
@@ -9653,7 +9569,7 @@ var executor = zod.z.object({
|
|
|
9653
9569
|
committedCount: counter,
|
|
9654
9570
|
lastCommittedFingerprint: zod.z.string().optional()
|
|
9655
9571
|
}).strict().optional()
|
|
9656
|
-
}).strict();
|
|
9572
|
+
}).strict().transform(({ lastSuccessfulLlmModelId: _retired, runLockedModelId: _retiredLock, ...state }) => state);
|
|
9657
9573
|
var checkpoint = zod.z.object({
|
|
9658
9574
|
nodeId: zod.z.string().min(1),
|
|
9659
9575
|
schemaVersion: zod.z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|
|
@@ -9715,7 +9631,7 @@ __export(execution_exports, {
|
|
|
9715
9631
|
});
|
|
9716
9632
|
|
|
9717
9633
|
// src/runtime-kernel/execution/event-bus.ts
|
|
9718
|
-
var
|
|
9634
|
+
var logger11 = new Logger("EventBus");
|
|
9719
9635
|
var TypedEventEmitter = class {
|
|
9720
9636
|
listeners = /* @__PURE__ */ new Map();
|
|
9721
9637
|
maxListeners = 10;
|
|
@@ -9723,7 +9639,7 @@ var TypedEventEmitter = class {
|
|
|
9723
9639
|
const listeners = this.getListeners(event);
|
|
9724
9640
|
listeners.add(listener);
|
|
9725
9641
|
if (listeners.size > this.maxListeners) {
|
|
9726
|
-
|
|
9642
|
+
logger11.warn("EventBus listener count exceeds configured max", {
|
|
9727
9643
|
event: String(event),
|
|
9728
9644
|
count: listeners.size,
|
|
9729
9645
|
maxListeners: this.maxListeners
|
|
@@ -9783,7 +9699,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9783
9699
|
super();
|
|
9784
9700
|
this.executionId = executionId;
|
|
9785
9701
|
this.setMaxListeners(30);
|
|
9786
|
-
|
|
9702
|
+
logger11.info(`EventBus created for execution ${this.executionId}`);
|
|
9787
9703
|
}
|
|
9788
9704
|
/**
|
|
9789
9705
|
* 发布一个事件到总线
|
|
@@ -9792,7 +9708,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9792
9708
|
publish(envelope) {
|
|
9793
9709
|
if (envelope.trace.execution_id !== this.executionId) {
|
|
9794
9710
|
const error = new Error("EventEnvelope execution_id does not match EventBus instance.");
|
|
9795
|
-
|
|
9711
|
+
logger11.error("Mismatched execution_id", {
|
|
9796
9712
|
busExecutionId: this.executionId,
|
|
9797
9713
|
eventExecutionId: envelope.trace.execution_id,
|
|
9798
9714
|
eventSeq: envelope.seq
|
|
@@ -9804,7 +9720,7 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9804
9720
|
const error = new Error(
|
|
9805
9721
|
"EventBus only accepts RuntimeEvent with formal run routing identity."
|
|
9806
9722
|
);
|
|
9807
|
-
|
|
9723
|
+
logger11.error("RuntimeEvent is missing formal run routing identity", {
|
|
9808
9724
|
executionId: this.executionId,
|
|
9809
9725
|
eventId: envelope.payload.id,
|
|
9810
9726
|
eventType: envelope.payload.type
|
|
@@ -9818,14 +9734,14 @@ var EventBus = class extends TypedEventEmitter {
|
|
|
9818
9734
|
* 关闭总线,清理所有监听器
|
|
9819
9735
|
*/
|
|
9820
9736
|
close() {
|
|
9821
|
-
|
|
9737
|
+
logger11.info(`Closing EventBus for execution ${this.executionId}`);
|
|
9822
9738
|
this.emit("close");
|
|
9823
9739
|
this.removeAllListeners();
|
|
9824
9740
|
}
|
|
9825
9741
|
};
|
|
9826
9742
|
|
|
9827
9743
|
// src/runtime-kernel/execution/sequencer.ts
|
|
9828
|
-
var
|
|
9744
|
+
var logger12 = new Logger("EventSequencer");
|
|
9829
9745
|
var EventSequencer = class {
|
|
9830
9746
|
executionId;
|
|
9831
9747
|
traceId;
|
|
@@ -9833,7 +9749,7 @@ var EventSequencer = class {
|
|
|
9833
9749
|
constructor(conversationId, traceId) {
|
|
9834
9750
|
this.executionId = generateExecutionId();
|
|
9835
9751
|
this.traceId = traceId || generateTraceId();
|
|
9836
|
-
|
|
9752
|
+
logger12.info(`EventSequencer created for conversation ${conversationId}`, {
|
|
9837
9753
|
executionId: this.executionId,
|
|
9838
9754
|
traceId: this.traceId
|
|
9839
9755
|
});
|
|
@@ -10646,7 +10562,7 @@ var ThoughtStreamSegmenter = class {
|
|
|
10646
10562
|
};
|
|
10647
10563
|
|
|
10648
10564
|
// src/runtime-kernel/llm/streaming-adapter.ts
|
|
10649
|
-
var
|
|
10565
|
+
var logger13 = new Logger("LlmCaller");
|
|
10650
10566
|
var CanonicalInferenceFailureError = class extends Error {
|
|
10651
10567
|
errorCode;
|
|
10652
10568
|
recoverable;
|
|
@@ -10870,7 +10786,7 @@ async function callLlmStream(params) {
|
|
|
10870
10786
|
} catch (error) {
|
|
10871
10787
|
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
10872
10788
|
if (normalized.name === "AbortError") {
|
|
10873
|
-
|
|
10789
|
+
logger13.info("Canonical inference \u6536\u5230\u53D6\u6D88\u7EC8\u6001\uFF0C\u4E0D\u53D1\u5E03\u666E\u901A error event", { modelId });
|
|
10874
10790
|
throw normalized;
|
|
10875
10791
|
}
|
|
10876
10792
|
const classification = ErrorClassifier.classify(normalized, {
|
|
@@ -10946,7 +10862,7 @@ var LlmRetryEpisode = class {
|
|
|
10946
10862
|
};
|
|
10947
10863
|
|
|
10948
10864
|
// src/runtime-kernel/llm/retry-fallback-routing.ts
|
|
10949
|
-
var
|
|
10865
|
+
var logger14 = new Logger("LlmCaller");
|
|
10950
10866
|
function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement, fallbackObserver, error, evaluateFallbackPromptCapacity2) {
|
|
10951
10867
|
deps.modelCatalog.getModelById(activeModelId);
|
|
10952
10868
|
const policyDecision = deps.policyEngine.decideOnError(error, {
|
|
@@ -10976,81 +10892,16 @@ function tryPolicyModelSwitch(deps, activeModelId, excludedModelIds, requirement
|
|
|
10976
10892
|
reason: "no_eligible_fallback_candidate",
|
|
10977
10893
|
requiredPlacements: requirement.placements
|
|
10978
10894
|
});
|
|
10979
|
-
|
|
10895
|
+
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");
|
|
10980
10896
|
return null;
|
|
10981
10897
|
}
|
|
10982
|
-
|
|
10898
|
+
logger14.warn("Policy \u5207\u6362\u6A21\u578B\u7EE7\u7EED", {
|
|
10983
10899
|
reason: policyDecision.reason,
|
|
10984
10900
|
activeModelId,
|
|
10985
10901
|
fallbackModelId
|
|
10986
10902
|
});
|
|
10987
10903
|
return fallbackModelId;
|
|
10988
10904
|
}
|
|
10989
|
-
function tryCloudQuotaFallback({
|
|
10990
|
-
deps,
|
|
10991
|
-
activeModelId,
|
|
10992
|
-
options,
|
|
10993
|
-
excludedModelIds,
|
|
10994
|
-
requirement,
|
|
10995
|
-
error,
|
|
10996
|
-
fallbackObserver,
|
|
10997
|
-
evaluateFallbackPromptCapacity: evaluateFallbackPromptCapacity2
|
|
10998
|
-
}) {
|
|
10999
|
-
const fallbackModelId = options.cloud_quota_fallback_model_id;
|
|
11000
|
-
if (!fallbackModelId || !ErrorClassifier.isCloudQuotaError(error) || excludedModelIds.has(fallbackModelId)) {
|
|
11001
|
-
return null;
|
|
11002
|
-
}
|
|
11003
|
-
const fallbackConfig = deps.modelCatalog.getModelById(fallbackModelId);
|
|
11004
|
-
if (!fallbackConfig?.api_key) {
|
|
11005
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11006
|
-
fromModelId: activeModelId,
|
|
11007
|
-
candidateModelId: fallbackModelId,
|
|
11008
|
-
policy: "cloud-quota",
|
|
11009
|
-
reason: "fallback_model_unavailable",
|
|
11010
|
-
requiredPlacements: requirement.placements
|
|
11011
|
-
});
|
|
11012
|
-
logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\u76EE\u6807\u4E0D\u53EF\u7528\uFF08\u672A\u6CE8\u518C\u6216\u7F3A\u5C11 API Key\uFF09", { fallbackModelId });
|
|
11013
|
-
return null;
|
|
11014
|
-
}
|
|
11015
|
-
const compatibility = evaluateModelInputCompatibility(fallbackConfig, requirement);
|
|
11016
|
-
if (!compatibility.compatible) {
|
|
11017
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11018
|
-
fromModelId: activeModelId,
|
|
11019
|
-
candidateModelId: fallbackModelId,
|
|
11020
|
-
policy: "cloud-quota",
|
|
11021
|
-
reason: compatibility.reason,
|
|
11022
|
-
requiredPlacements: requirement.placements
|
|
11023
|
-
});
|
|
11024
|
-
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", {
|
|
11025
|
-
fallbackModelId,
|
|
11026
|
-
requiredPlacements: requirement.placements,
|
|
11027
|
-
reason: compatibility.reason
|
|
11028
|
-
});
|
|
11029
|
-
return null;
|
|
11030
|
-
}
|
|
11031
|
-
const capacityAdmission = evaluateFallbackPromptCapacity2?.(fallbackModelId);
|
|
11032
|
-
if (capacityAdmission && !capacityAdmission.admitted) {
|
|
11033
|
-
fallbackObserver?.onModelFallbackRejected?.({
|
|
11034
|
-
fromModelId: activeModelId,
|
|
11035
|
-
candidateModelId: fallbackModelId,
|
|
11036
|
-
policy: "cloud-quota",
|
|
11037
|
-
reason: capacityAdmission.reason,
|
|
11038
|
-
requiredPlacements: requirement.placements
|
|
11039
|
-
});
|
|
11040
|
-
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", {
|
|
11041
|
-
fallbackModelId,
|
|
11042
|
-
reason: capacityAdmission.reason
|
|
11043
|
-
});
|
|
11044
|
-
return null;
|
|
11045
|
-
}
|
|
11046
|
-
logger15.warn("\u4E91\u7AEF\u9650\u989D\u964D\u7EA7\uFF08run \u5185\u7EED\u8DD1\uFF09", {
|
|
11047
|
-
activeModelId,
|
|
11048
|
-
fallbackModelId,
|
|
11049
|
-
reason: error.message
|
|
11050
|
-
});
|
|
11051
|
-
fallbackObserver?.onCloudQuotaFallbackApplied?.(fallbackModelId);
|
|
11052
|
-
return fallbackModelId;
|
|
11053
|
-
}
|
|
11054
10905
|
|
|
11055
10906
|
// src/runtime-kernel/llm/usage-telemetry.ts
|
|
11056
10907
|
async function callPlainCompletion(inferencePort, modelId, messages, options = {}, signal, traceId) {
|
|
@@ -11153,7 +11004,7 @@ async function runLlmInputPreflight(params) {
|
|
|
11153
11004
|
}
|
|
11154
11005
|
|
|
11155
11006
|
// src/runtime-kernel/llm/retry-fallback.ts
|
|
11156
|
-
var
|
|
11007
|
+
var logger15 = new Logger("LlmCaller");
|
|
11157
11008
|
async function callWithRetryFallback(params) {
|
|
11158
11009
|
const {
|
|
11159
11010
|
deps,
|
|
@@ -11181,11 +11032,9 @@ async function callWithRetryFallback(params) {
|
|
|
11181
11032
|
const retryEpisode = new LlmRetryEpisode(traceId, eventHandler);
|
|
11182
11033
|
let previousAttemptTracker;
|
|
11183
11034
|
if (!clientRetryEnabled) {
|
|
11184
|
-
|
|
11185
|
-
logger16.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
|
|
11035
|
+
logger15.debug("\u5BA2\u6237\u7AEF\u91CD\u8BD5\u5DF2\u7981\u7528", {
|
|
11186
11036
|
modelId,
|
|
11187
|
-
|
|
11188
|
-
reason: options.retry_policy === "none" ? "options.retry_policy=none" : "model config (cloud billing or enable_client_retry=false)"
|
|
11037
|
+
reason: options.retry_policy === "none" ? "options.retry_policy=none" : "model config enable_client_retry=false"
|
|
11189
11038
|
});
|
|
11190
11039
|
}
|
|
11191
11040
|
try {
|
|
@@ -11221,7 +11070,7 @@ async function callWithRetryFallback(params) {
|
|
|
11221
11070
|
}) : void 0;
|
|
11222
11071
|
try {
|
|
11223
11072
|
if (isRetry) {
|
|
11224
|
-
|
|
11073
|
+
logger15.info("LLM \u8C03\u7528\u91CD\u8BD5", { attempt, configuredMaxRetries });
|
|
11225
11074
|
}
|
|
11226
11075
|
actualAttempts++;
|
|
11227
11076
|
retryEpisode.retrying(actualAttempts);
|
|
@@ -11250,7 +11099,7 @@ async function callWithRetryFallback(params) {
|
|
|
11250
11099
|
if (deps.retryConfig.enableEmptyResponseRetry && !responseContent?.trim() && !toolCallsFromLLM?.length) {
|
|
11251
11100
|
throw new Error("LLM\u8FD4\u56DE\u4E86\u7A7A\u54CD\u5E94");
|
|
11252
11101
|
}
|
|
11253
|
-
|
|
11102
|
+
logger15.debug("LLM \u8C03\u7528\u6210\u529F", { attempts: actualAttempts, maxTotalAttempts });
|
|
11254
11103
|
if (attemptContextUsage) {
|
|
11255
11104
|
fallbackObserver?.onLlmAttemptSucceeded?.(activeModelId, attemptContextUsage);
|
|
11256
11105
|
} else {
|
|
@@ -11261,7 +11110,7 @@ async function callWithRetryFallback(params) {
|
|
|
11261
11110
|
} catch (error) {
|
|
11262
11111
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
11263
11112
|
if (lastError.name === "AbortError") {
|
|
11264
|
-
|
|
11113
|
+
logger15.info("LLM \u8C03\u7528\u5DF2\u53D6\u6D88\uFF0C\u4E0D\u8FDB\u5165 provider failure \u5206\u7C7B\u4E0E\u91CD\u8BD5\u6D41\u7A0B", {
|
|
11265
11114
|
attempt: attempt + 1,
|
|
11266
11115
|
actualAttempts,
|
|
11267
11116
|
maxTotalAttempts,
|
|
@@ -11280,7 +11129,7 @@ async function callWithRetryFallback(params) {
|
|
|
11280
11129
|
total_attempts: actualAttempts,
|
|
11281
11130
|
error_code: classification.errorCode
|
|
11282
11131
|
};
|
|
11283
|
-
|
|
11132
|
+
logger15.error("LLM \u8C03\u7528\u5931\u8D25", {
|
|
11284
11133
|
attempt: attempt + 1,
|
|
11285
11134
|
maxAttempts: currentMaxRetries + 1,
|
|
11286
11135
|
actualAttempts,
|
|
@@ -11289,7 +11138,7 @@ async function callWithRetryFallback(params) {
|
|
|
11289
11138
|
});
|
|
11290
11139
|
previousAttemptTracker = attemptTracker;
|
|
11291
11140
|
if (!hasLlmAttemptBudgetRemaining({ actualAttempts, maxTotalAttempts })) {
|
|
11292
|
-
|
|
11141
|
+
logger15.error("\u5DF2\u8FBE\u5230 LLM \u603B\u8C03\u7528\u6B21\u6570\u4E0A\u9650\uFF0C\u505C\u6B62\u91CD\u8BD5/\u5207\u6A21\u578B", {
|
|
11293
11142
|
actualAttempts,
|
|
11294
11143
|
maxTotalAttempts
|
|
11295
11144
|
});
|
|
@@ -11319,37 +11168,15 @@ async function callWithRetryFallback(params) {
|
|
|
11319
11168
|
attempt -= 1;
|
|
11320
11169
|
continue;
|
|
11321
11170
|
}
|
|
11322
|
-
const quotaFallbackModelId = tryCloudQuotaFallback({
|
|
11323
|
-
deps,
|
|
11324
|
-
activeModelId,
|
|
11325
|
-
options,
|
|
11326
|
-
excludedModelIds,
|
|
11327
|
-
requirement,
|
|
11328
|
-
error: lastError,
|
|
11329
|
-
fallbackObserver,
|
|
11330
|
-
evaluateFallbackPromptCapacity: invocationContext?.evaluateFallbackPromptCapacity
|
|
11331
|
-
});
|
|
11332
|
-
if (quotaFallbackModelId) {
|
|
11333
|
-
fallbackObserver?.onModelFallbackApplied?.({
|
|
11334
|
-
fromModelId: activeModelId,
|
|
11335
|
-
toModelId: quotaFallbackModelId,
|
|
11336
|
-
reason: lastError.message,
|
|
11337
|
-
policy: "cloud-quota"
|
|
11338
|
-
});
|
|
11339
|
-
activeModelId = quotaFallbackModelId;
|
|
11340
|
-
excludedModelIds.add(quotaFallbackModelId);
|
|
11341
|
-
attempt -= 1;
|
|
11342
|
-
continue;
|
|
11343
|
-
}
|
|
11344
11171
|
}
|
|
11345
11172
|
if (classification.category === "non_retryable" /* NON_RETRYABLE */) {
|
|
11346
|
-
|
|
11173
|
+
logger15.error("\u9519\u8BEF\u4E0D\u53EF\u91CD\u8BD5\uFF0C\u76F4\u63A5\u5931\u8D25", { reason: classification.reason });
|
|
11347
11174
|
retryEpisode.finish("failed", failedRetryState);
|
|
11348
11175
|
emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
|
|
11349
11176
|
throw lastError;
|
|
11350
11177
|
}
|
|
11351
11178
|
if (attempt >= configuredMaxRetries || categoryRetries[category] >= currentMaxRetries) {
|
|
11352
|
-
|
|
11179
|
+
logger15.error("\u5DF2\u8FBE\u5230\u6700\u5927\u91CD\u8BD5\u6B21\u6570\uFF0C\u653E\u5F03\u91CD\u8BD5", { maxRetries: currentMaxRetries });
|
|
11353
11180
|
retryEpisode.finish("exhausted", failedRetryState);
|
|
11354
11181
|
emitFinalError(eventHandler, pendingErrorEvent, lastError, classification, retryEpisode.activeId);
|
|
11355
11182
|
throw lastError;
|
|
@@ -11361,9 +11188,9 @@ async function callWithRetryFallback(params) {
|
|
|
11361
11188
|
6e4
|
|
11362
11189
|
);
|
|
11363
11190
|
if (classification.category === "rate_limit" /* RATE_LIMIT */) {
|
|
11364
|
-
|
|
11191
|
+
logger15.warn("\u901F\u7387\u9650\u5236\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
|
|
11365
11192
|
} else if (classification.category === "retryable" /* RETRYABLE */) {
|
|
11366
|
-
|
|
11193
|
+
logger15.warn("\u53EF\u91CD\u8BD5\u9519\u8BEF\uFF0C\u5EF6\u8FDF\u540E\u91CD\u8BD5", { retryDelay, reason: classification.reason });
|
|
11367
11194
|
}
|
|
11368
11195
|
throwIfAborted(signal, "\u5EF6\u8FDF\u7B49\u5F85\u524D\u68C0\u6D4B\u5230\u53D6\u6D88\u4FE1\u53F7\uFF0C\u505C\u6B62\u91CD\u8BD5");
|
|
11369
11196
|
categoryRetries[category] += 1;
|
|
@@ -11400,16 +11227,11 @@ function waitForRetry(delayMs, signal) {
|
|
|
11400
11227
|
}
|
|
11401
11228
|
function isClientRetryEnabledForModel(modelCatalog, modelId, options) {
|
|
11402
11229
|
if (options.retry_policy === "none") return false;
|
|
11403
|
-
|
|
11404
|
-
if (cfg?.billing_mode === "cloud") return false;
|
|
11405
|
-
if (options.retry_policy === "client") return true;
|
|
11406
|
-
if (!cfg) return true;
|
|
11407
|
-
if (cfg.enable_client_retry === false) return false;
|
|
11408
|
-
return true;
|
|
11230
|
+
return modelCatalog.getModelById(modelId)?.enable_client_retry !== false;
|
|
11409
11231
|
}
|
|
11410
11232
|
function throwIfAborted(signal, message) {
|
|
11411
11233
|
if (!signal?.aborted) return;
|
|
11412
|
-
|
|
11234
|
+
logger15.info(message);
|
|
11413
11235
|
const reason = signal.reason;
|
|
11414
11236
|
if (reason instanceof Error && reason.name === "AbortError") throw reason;
|
|
11415
11237
|
const reasonText = typeof reason === "string" && reason.trim().length > 0 ? reason : "stream_interrupted";
|
|
@@ -12092,7 +11914,7 @@ function runMetaFromRecord(record) {
|
|
|
12092
11914
|
}
|
|
12093
11915
|
|
|
12094
11916
|
// src/runtime-kernel/run-supervisor/functions/awaitingUserWatcher.ts
|
|
12095
|
-
var
|
|
11917
|
+
var logger17 = new Logger("RunSupervisorAwaitingUserWatcher");
|
|
12096
11918
|
function isRecord16(value) {
|
|
12097
11919
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12098
11920
|
}
|
|
@@ -12137,7 +11959,7 @@ function createAwaitingUserWatcher(options) {
|
|
|
12137
11959
|
resumeToken: event.resume_token
|
|
12138
11960
|
}
|
|
12139
11961
|
}).catch((error) => {
|
|
12140
|
-
|
|
11962
|
+
logger17.warn("failed to mark awaiting_user from requires_user_interaction", { error });
|
|
12141
11963
|
});
|
|
12142
11964
|
};
|
|
12143
11965
|
const dispose = () => {
|