@inkeep/agents-run-api 0.11.2 → 0.12.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/dist/index.cjs
CHANGED
|
@@ -343,8 +343,8 @@ async function getConversationScopedArtifacts(params) {
|
|
|
343
343
|
});
|
|
344
344
|
referenceArtifacts.push(...artifacts);
|
|
345
345
|
}
|
|
346
|
-
const
|
|
347
|
-
|
|
346
|
+
const logger25 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
|
|
347
|
+
logger25.debug(
|
|
348
348
|
{
|
|
349
349
|
conversationId,
|
|
350
350
|
visibleMessages: visibleMessages.length,
|
|
@@ -356,8 +356,8 @@ async function getConversationScopedArtifacts(params) {
|
|
|
356
356
|
);
|
|
357
357
|
return referenceArtifacts;
|
|
358
358
|
} catch (error) {
|
|
359
|
-
const
|
|
360
|
-
|
|
359
|
+
const logger25 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
|
|
360
|
+
logger25.error(
|
|
361
361
|
{
|
|
362
362
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
363
363
|
conversationId
|
|
@@ -1772,6 +1772,7 @@ var toolSessionManager = ToolSessionManager.getInstance();
|
|
|
1772
1772
|
|
|
1773
1773
|
// src/services/GraphSession.ts
|
|
1774
1774
|
init_conversations();
|
|
1775
|
+
init_dbClient();
|
|
1775
1776
|
init_logger();
|
|
1776
1777
|
|
|
1777
1778
|
// src/utils/default-status-schemas.ts
|
|
@@ -1856,7 +1857,7 @@ var _ArtifactService = class _ArtifactService {
|
|
|
1856
1857
|
/**
|
|
1857
1858
|
* Create artifact from tool result and request data
|
|
1858
1859
|
*/
|
|
1859
|
-
async createArtifact(request) {
|
|
1860
|
+
async createArtifact(request, agentId) {
|
|
1860
1861
|
if (!this.context.sessionId) {
|
|
1861
1862
|
logger6.warn({ request }, "No session ID available for artifact creation");
|
|
1862
1863
|
return null;
|
|
@@ -1907,7 +1908,7 @@ var _ArtifactService = class _ArtifactService {
|
|
|
1907
1908
|
type: request.type,
|
|
1908
1909
|
artifactSummary: component?.summaryProps ? this.filterBySchema(cleanedSummaryData, component.summaryProps) : cleanedSummaryData
|
|
1909
1910
|
};
|
|
1910
|
-
await this.persistArtifact(request, cleanedSummaryData, cleanedFullData);
|
|
1911
|
+
await this.persistArtifact(request, cleanedSummaryData, cleanedFullData, agentId);
|
|
1911
1912
|
await this.cacheArtifact(
|
|
1912
1913
|
request.artifactId,
|
|
1913
1914
|
request.toolCallId,
|
|
@@ -1983,12 +1984,13 @@ var _ArtifactService = class _ArtifactService {
|
|
|
1983
1984
|
/**
|
|
1984
1985
|
* Persist artifact to database via graph session
|
|
1985
1986
|
*/
|
|
1986
|
-
async persistArtifact(request, summaryData, fullData) {
|
|
1987
|
-
|
|
1987
|
+
async persistArtifact(request, summaryData, fullData, agentId) {
|
|
1988
|
+
const effectiveAgentId = agentId || this.context.agentId;
|
|
1989
|
+
if (this.context.streamRequestId && effectiveAgentId && this.context.taskId) {
|
|
1988
1990
|
await graphSessionManager.recordEvent(
|
|
1989
1991
|
this.context.streamRequestId,
|
|
1990
1992
|
"artifact_saved",
|
|
1991
|
-
|
|
1993
|
+
effectiveAgentId,
|
|
1992
1994
|
{
|
|
1993
1995
|
artifactId: request.artifactId,
|
|
1994
1996
|
taskId: this.context.taskId,
|
|
@@ -1996,6 +1998,7 @@ var _ArtifactService = class _ArtifactService {
|
|
|
1996
1998
|
artifactType: request.type,
|
|
1997
1999
|
summaryProps: summaryData,
|
|
1998
2000
|
fullProps: fullData,
|
|
2001
|
+
agentId: effectiveAgentId,
|
|
1999
2002
|
metadata: {
|
|
2000
2003
|
toolCallId: request.toolCallId,
|
|
2001
2004
|
baseSelector: request.baseSelector,
|
|
@@ -2010,6 +2013,15 @@ var _ArtifactService = class _ArtifactService {
|
|
|
2010
2013
|
pendingGeneration: true
|
|
2011
2014
|
}
|
|
2012
2015
|
);
|
|
2016
|
+
} else {
|
|
2017
|
+
logger6.warn({
|
|
2018
|
+
artifactId: request.artifactId,
|
|
2019
|
+
hasStreamRequestId: !!this.context.streamRequestId,
|
|
2020
|
+
hasAgentId: !!effectiveAgentId,
|
|
2021
|
+
hasTaskId: !!this.context.taskId,
|
|
2022
|
+
passedAgentId: agentId,
|
|
2023
|
+
contextAgentId: this.context.agentId
|
|
2024
|
+
}, "Skipping artifact_saved event - missing required context");
|
|
2013
2025
|
}
|
|
2014
2026
|
}
|
|
2015
2027
|
/**
|
|
@@ -2184,7 +2196,10 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2184
2196
|
* Check if text contains complete artifact markers (ref or create)
|
|
2185
2197
|
*/
|
|
2186
2198
|
hasArtifactMarkers(text) {
|
|
2187
|
-
|
|
2199
|
+
const refMatch = _ArtifactParser.ARTIFACT_CHECK_REGEX.test(text);
|
|
2200
|
+
const createRegex = /<artifact:create\s+([^>]+?)(?:\s*\/)?>(?:(.*?)<\/artifact:create>)?/gs;
|
|
2201
|
+
const createMatch = createRegex.test(text);
|
|
2202
|
+
return refMatch || createMatch;
|
|
2188
2203
|
}
|
|
2189
2204
|
/**
|
|
2190
2205
|
* Check if text has incomplete artifact marker (for streaming)
|
|
@@ -2250,7 +2265,6 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2250
2265
|
}
|
|
2251
2266
|
attrs[key] = value;
|
|
2252
2267
|
}
|
|
2253
|
-
logger7.debug({ attrs, attrString }, "Parsed artifact:create attributes");
|
|
2254
2268
|
if (!attrs.id || !attrs.tool || !attrs.type || !attrs.base) {
|
|
2255
2269
|
logger7.warn({ attrs, attrString }, "Missing required attributes in artifact annotation");
|
|
2256
2270
|
return null;
|
|
@@ -2269,15 +2283,10 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2269
2283
|
*/
|
|
2270
2284
|
parseCreateAnnotations(text) {
|
|
2271
2285
|
const annotations = [];
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2274
|
-
textContainsCreate: text.includes("artifact:create"),
|
|
2275
|
-
matchCount: matches.length,
|
|
2276
|
-
textLength: text.length
|
|
2277
|
-
}, "parseCreateAnnotations called");
|
|
2286
|
+
const createRegex = /<artifact:create\s+([^>]+?)(?:\s*\/)?>(?:(.*?)<\/artifact:create>)?/gs;
|
|
2287
|
+
const matches = [...text.matchAll(createRegex)];
|
|
2278
2288
|
for (const match of matches) {
|
|
2279
2289
|
const [fullMatch, attributes] = match;
|
|
2280
|
-
logger7.debug({ fullMatch, attributes }, "Found artifact:create match");
|
|
2281
2290
|
const annotation = this.parseCreateAttributes(attributes);
|
|
2282
2291
|
if (annotation) {
|
|
2283
2292
|
annotation.raw = fullMatch;
|
|
@@ -2289,7 +2298,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2289
2298
|
/**
|
|
2290
2299
|
* Extract artifact data from a create annotation - delegates to service
|
|
2291
2300
|
*/
|
|
2292
|
-
async extractFromCreateAnnotation(annotation) {
|
|
2301
|
+
async extractFromCreateAnnotation(annotation, agentId) {
|
|
2293
2302
|
const request = {
|
|
2294
2303
|
artifactId: annotation.artifactId,
|
|
2295
2304
|
toolCallId: annotation.toolCallId,
|
|
@@ -2298,32 +2307,27 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2298
2307
|
summaryProps: annotation.summaryProps,
|
|
2299
2308
|
fullProps: annotation.fullProps
|
|
2300
2309
|
};
|
|
2301
|
-
return this.artifactService.createArtifact(request);
|
|
2310
|
+
return this.artifactService.createArtifact(request, agentId);
|
|
2302
2311
|
}
|
|
2303
2312
|
/**
|
|
2304
2313
|
* Parse text with artifact markers into parts array
|
|
2305
2314
|
* Handles both artifact:ref and artifact:create tags
|
|
2306
2315
|
* Can work with or without pre-fetched artifact map
|
|
2307
2316
|
*/
|
|
2308
|
-
async parseText(text, artifactMap) {
|
|
2317
|
+
async parseText(text, artifactMap, agentId) {
|
|
2309
2318
|
let processedText = text;
|
|
2310
2319
|
const createAnnotations = this.parseCreateAnnotations(text);
|
|
2311
|
-
logger7.debug({
|
|
2312
|
-
hasCreateAnnotations: createAnnotations.length > 0,
|
|
2313
|
-
annotationCount: createAnnotations.length,
|
|
2314
|
-
textLength: text.length
|
|
2315
|
-
}, "Processing text for artifact annotations");
|
|
2316
2320
|
const createdArtifactData = /* @__PURE__ */ new Map();
|
|
2317
2321
|
const failedAnnotations = [];
|
|
2318
2322
|
for (const annotation of createAnnotations) {
|
|
2319
2323
|
try {
|
|
2320
|
-
const artifactData = await this.extractFromCreateAnnotation(annotation);
|
|
2324
|
+
const artifactData = await this.extractFromCreateAnnotation(annotation, agentId);
|
|
2321
2325
|
if (artifactData && annotation.raw) {
|
|
2322
2326
|
createdArtifactData.set(annotation.raw, artifactData);
|
|
2323
2327
|
} else if (annotation.raw) {
|
|
2324
2328
|
failedAnnotations.push(`Failed to create artifact "${annotation.artifactId}": Missing or invalid data`);
|
|
2325
2329
|
processedText = processedText.replace(annotation.raw, "");
|
|
2326
|
-
logger7.warn({ annotation }, "Removed failed artifact:create annotation from output");
|
|
2330
|
+
logger7.warn({ annotation, artifactData }, "Removed failed artifact:create annotation from output");
|
|
2327
2331
|
}
|
|
2328
2332
|
} catch (error) {
|
|
2329
2333
|
const errorMsg = error instanceof Error ? error.message : "Unknown error";
|
|
@@ -2341,8 +2345,10 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2341
2345
|
}, "Some artifact creation attempts failed");
|
|
2342
2346
|
}
|
|
2343
2347
|
const parts = [];
|
|
2344
|
-
const
|
|
2345
|
-
const
|
|
2348
|
+
const createRegex = /<artifact:create\s+([^>]+?)(?:\s*\/)?>(?:(.*?)<\/artifact:create>)?/gs;
|
|
2349
|
+
const refRegex = /<artifact:ref\s+id=(["'])([^"']*?)\1\s+tool=(["'])([^"']*?)\3\s*\/>/gs;
|
|
2350
|
+
const createMatches = [...text.matchAll(createRegex)];
|
|
2351
|
+
const refMatches = [...processedText.matchAll(refRegex)];
|
|
2346
2352
|
const allMatches = [
|
|
2347
2353
|
...createMatches.map((match) => ({ match, type: "create" })),
|
|
2348
2354
|
...refMatches.map((match) => ({ match, type: "ref" }))
|
|
@@ -2384,7 +2390,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2384
2390
|
/**
|
|
2385
2391
|
* Process object/dataComponents for artifact components
|
|
2386
2392
|
*/
|
|
2387
|
-
async parseObject(obj, artifactMap) {
|
|
2393
|
+
async parseObject(obj, artifactMap, agentId) {
|
|
2388
2394
|
if (obj?.dataComponents && Array.isArray(obj.dataComponents)) {
|
|
2389
2395
|
const parts = [];
|
|
2390
2396
|
for (const component of obj.dataComponents) {
|
|
@@ -2398,7 +2404,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2398
2404
|
parts.push({ kind: "data", data: artifactData });
|
|
2399
2405
|
}
|
|
2400
2406
|
} else if (this.isArtifactCreateComponent(component)) {
|
|
2401
|
-
const createData = await this.extractFromArtifactCreateComponent(component);
|
|
2407
|
+
const createData = await this.extractFromArtifactCreateComponent(component, agentId);
|
|
2402
2408
|
if (createData) {
|
|
2403
2409
|
parts.push({ kind: "data", data: createData });
|
|
2404
2410
|
}
|
|
@@ -2417,7 +2423,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2417
2423
|
return artifactData ? [{ kind: "data", data: artifactData }] : [];
|
|
2418
2424
|
}
|
|
2419
2425
|
if (this.isArtifactCreateComponent(obj)) {
|
|
2420
|
-
const createData = await this.extractFromArtifactCreateComponent(obj);
|
|
2426
|
+
const createData = await this.extractFromArtifactCreateComponent(obj, agentId);
|
|
2421
2427
|
return createData ? [{ kind: "data", data: createData }] : [];
|
|
2422
2428
|
}
|
|
2423
2429
|
return [{ kind: "data", data: obj }];
|
|
@@ -2426,15 +2432,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2426
2432
|
* Check if object is an artifact component
|
|
2427
2433
|
*/
|
|
2428
2434
|
isArtifactComponent(obj) {
|
|
2429
|
-
|
|
2430
|
-
logger7.debug({
|
|
2431
|
-
obj,
|
|
2432
|
-
name: obj?.name,
|
|
2433
|
-
artifact_id: obj?.props?.artifact_id,
|
|
2434
|
-
tool_call_id: obj?.props?.tool_call_id,
|
|
2435
|
-
result
|
|
2436
|
-
}, "isArtifactComponent check");
|
|
2437
|
-
return result;
|
|
2435
|
+
return obj?.name === "Artifact" && obj?.props?.artifact_id && obj?.props?.tool_call_id;
|
|
2438
2436
|
}
|
|
2439
2437
|
/**
|
|
2440
2438
|
* Check if object is an artifact create component
|
|
@@ -2445,7 +2443,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2445
2443
|
/**
|
|
2446
2444
|
* Extract artifact from ArtifactCreate component
|
|
2447
2445
|
*/
|
|
2448
|
-
async extractFromArtifactCreateComponent(component) {
|
|
2446
|
+
async extractFromArtifactCreateComponent(component, agentId) {
|
|
2449
2447
|
const props = component.props;
|
|
2450
2448
|
if (!props) {
|
|
2451
2449
|
return null;
|
|
@@ -2458,7 +2456,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2458
2456
|
summaryProps: props.summary_props || {},
|
|
2459
2457
|
fullProps: props.full_props || {}
|
|
2460
2458
|
};
|
|
2461
|
-
return await this.extractFromCreateAnnotation(annotation);
|
|
2459
|
+
return await this.extractFromCreateAnnotation(annotation, agentId);
|
|
2462
2460
|
}
|
|
2463
2461
|
/**
|
|
2464
2462
|
* Get artifact data - delegates to service
|
|
@@ -2636,7 +2634,8 @@ var GraphSession = class {
|
|
|
2636
2634
|
}
|
|
2637
2635
|
this.pendingArtifacts.add(artifactId);
|
|
2638
2636
|
setImmediate(() => {
|
|
2639
|
-
|
|
2637
|
+
const artifactDataWithAgent = { ...data, agentId };
|
|
2638
|
+
this.processArtifact(artifactDataWithAgent).then(() => {
|
|
2640
2639
|
this.pendingArtifacts.delete(artifactId);
|
|
2641
2640
|
this.artifactProcessingErrors.delete(artifactId);
|
|
2642
2641
|
}).catch((error) => {
|
|
@@ -3359,82 +3358,139 @@ Make it specific and relevant.`;
|
|
|
3359
3358
|
let modelToUse = this.statusUpdateState?.summarizerModel;
|
|
3360
3359
|
if (!modelToUse?.model?.trim()) {
|
|
3361
3360
|
if (!this.statusUpdateState?.baseModel?.model?.trim()) {
|
|
3362
|
-
|
|
3363
|
-
"Either summarizer or base model is required for artifact name generation. Please configure models at the project level."
|
|
3364
|
-
);
|
|
3365
|
-
}
|
|
3366
|
-
modelToUse = this.statusUpdateState.baseModel;
|
|
3367
|
-
}
|
|
3368
|
-
if (!modelToUse) {
|
|
3369
|
-
throw new Error("No model configuration available");
|
|
3370
|
-
}
|
|
3371
|
-
const model = ModelFactory.createModel(modelToUse);
|
|
3372
|
-
const schema = z5.z.object({
|
|
3373
|
-
name: z5.z.string().describe("Concise, descriptive name for the artifact"),
|
|
3374
|
-
description: z5.z.string().describe("Brief description of the artifact's relevance to the user's question")
|
|
3375
|
-
});
|
|
3376
|
-
const { object: result } = await tracer.startActiveSpan(
|
|
3377
|
-
"graph_session.generate_artifact_metadata",
|
|
3378
|
-
{
|
|
3379
|
-
attributes: {
|
|
3380
|
-
"llm.model": this.statusUpdateState?.summarizerModel?.model,
|
|
3381
|
-
"llm.operation": "generate_object",
|
|
3382
|
-
"artifact.id": artifactData.artifactId,
|
|
3383
|
-
"prompt.length": prompt.length
|
|
3384
|
-
}
|
|
3385
|
-
},
|
|
3386
|
-
async (generationSpan) => {
|
|
3387
|
-
const maxRetries = 3;
|
|
3388
|
-
let lastError = null;
|
|
3389
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
3361
|
+
if (artifactData.agentId && artifactData.tenantId && artifactData.projectId) {
|
|
3390
3362
|
try {
|
|
3391
|
-
const
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
recordInputs: true,
|
|
3399
|
-
recordOutputs: true,
|
|
3400
|
-
metadata: {
|
|
3401
|
-
operation: "artifact_name_description_generation",
|
|
3402
|
-
sessionId: this.sessionId,
|
|
3403
|
-
attempt
|
|
3404
|
-
}
|
|
3405
|
-
}
|
|
3406
|
-
});
|
|
3407
|
-
generationSpan.setAttributes({
|
|
3408
|
-
"generation.name_length": result2.object.name.length,
|
|
3409
|
-
"generation.description_length": result2.object.description.length,
|
|
3410
|
-
"generation.attempts": attempt
|
|
3363
|
+
const agentData = await agentsCore.getAgentById(dbClient_default)({
|
|
3364
|
+
scopes: {
|
|
3365
|
+
tenantId: artifactData.tenantId,
|
|
3366
|
+
projectId: artifactData.projectId,
|
|
3367
|
+
graphId: this.graphId || ""
|
|
3368
|
+
},
|
|
3369
|
+
agentId: artifactData.agentId
|
|
3411
3370
|
});
|
|
3412
|
-
|
|
3413
|
-
|
|
3371
|
+
if (agentData && "models" in agentData && agentData.models?.base?.model) {
|
|
3372
|
+
modelToUse = agentData.models.base;
|
|
3373
|
+
logger8.info(
|
|
3374
|
+
{
|
|
3375
|
+
sessionId: this.sessionId,
|
|
3376
|
+
artifactId: artifactData.artifactId,
|
|
3377
|
+
agentId: artifactData.agentId,
|
|
3378
|
+
model: modelToUse.model
|
|
3379
|
+
},
|
|
3380
|
+
"Using agent model configuration for artifact name generation"
|
|
3381
|
+
);
|
|
3382
|
+
}
|
|
3414
3383
|
} catch (error) {
|
|
3415
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
3416
3384
|
logger8.warn(
|
|
3417
3385
|
{
|
|
3418
3386
|
sessionId: this.sessionId,
|
|
3419
3387
|
artifactId: artifactData.artifactId,
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
error: lastError.message
|
|
3388
|
+
agentId: artifactData.agentId,
|
|
3389
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
3423
3390
|
},
|
|
3424
|
-
|
|
3391
|
+
"Failed to get agent model configuration"
|
|
3425
3392
|
);
|
|
3426
|
-
if (attempt < maxRetries) {
|
|
3427
|
-
const backoffMs = Math.min(1e3 * 2 ** (attempt - 1), 1e4);
|
|
3428
|
-
await new Promise((resolve) => setTimeout(resolve, backoffMs));
|
|
3429
|
-
}
|
|
3430
3393
|
}
|
|
3431
3394
|
}
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3395
|
+
if (!modelToUse?.model?.trim()) {
|
|
3396
|
+
logger8.warn(
|
|
3397
|
+
{
|
|
3398
|
+
sessionId: this.sessionId,
|
|
3399
|
+
artifactId: artifactData.artifactId
|
|
3400
|
+
},
|
|
3401
|
+
"No model configuration available for artifact name generation, will use fallback names"
|
|
3402
|
+
);
|
|
3403
|
+
modelToUse = void 0;
|
|
3404
|
+
}
|
|
3405
|
+
} else {
|
|
3406
|
+
modelToUse = this.statusUpdateState.baseModel;
|
|
3436
3407
|
}
|
|
3437
|
-
|
|
3408
|
+
}
|
|
3409
|
+
let result;
|
|
3410
|
+
if (!modelToUse) {
|
|
3411
|
+
result = {
|
|
3412
|
+
name: `Artifact ${artifactData.artifactId.substring(0, 8)}`,
|
|
3413
|
+
description: `${artifactData.artifactType || "Data"} from ${artifactData.metadata?.toolCallId || "tool results"}`
|
|
3414
|
+
};
|
|
3415
|
+
} else {
|
|
3416
|
+
const model = ModelFactory.createModel(modelToUse);
|
|
3417
|
+
const schema = z5.z.object({
|
|
3418
|
+
name: z5.z.string().describe("Concise, descriptive name for the artifact"),
|
|
3419
|
+
description: z5.z.string().describe("Brief description of the artifact's relevance to the user's question")
|
|
3420
|
+
});
|
|
3421
|
+
const { object } = await tracer.startActiveSpan(
|
|
3422
|
+
"graph_session.generate_artifact_metadata",
|
|
3423
|
+
{
|
|
3424
|
+
attributes: {
|
|
3425
|
+
"llm.model": this.statusUpdateState?.summarizerModel?.model,
|
|
3426
|
+
"llm.operation": "generate_object",
|
|
3427
|
+
"artifact.id": artifactData.artifactId,
|
|
3428
|
+
"artifact.type": artifactData.artifactType,
|
|
3429
|
+
"artifact.summary": JSON.stringify(artifactData.summaryProps, null, 2),
|
|
3430
|
+
"artifact.full": JSON.stringify(artifactData.fullProps, null, 2),
|
|
3431
|
+
"prompt.length": prompt.length
|
|
3432
|
+
}
|
|
3433
|
+
},
|
|
3434
|
+
async (generationSpan) => {
|
|
3435
|
+
const maxRetries = 3;
|
|
3436
|
+
let lastError = null;
|
|
3437
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
3438
|
+
try {
|
|
3439
|
+
const result2 = await ai.generateObject({
|
|
3440
|
+
model,
|
|
3441
|
+
prompt,
|
|
3442
|
+
schema,
|
|
3443
|
+
experimental_telemetry: {
|
|
3444
|
+
isEnabled: true,
|
|
3445
|
+
functionId: `artifact_processing_${artifactData.artifactId}`,
|
|
3446
|
+
recordInputs: true,
|
|
3447
|
+
recordOutputs: true,
|
|
3448
|
+
metadata: {
|
|
3449
|
+
operation: "artifact_name_description_generation",
|
|
3450
|
+
sessionId: this.sessionId,
|
|
3451
|
+
attempt
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
});
|
|
3455
|
+
generationSpan.setAttributes({
|
|
3456
|
+
"artifact.id": artifactData.artifactId,
|
|
3457
|
+
"artifact.type": artifactData.artifactType,
|
|
3458
|
+
"artifact.name": result2.object.name,
|
|
3459
|
+
"artifact.description": result2.object.description,
|
|
3460
|
+
"artifact.summary": JSON.stringify(artifactData.summaryProps, null, 2),
|
|
3461
|
+
"artifact.full": JSON.stringify(artifactData.fullProps, null, 2),
|
|
3462
|
+
"generation.name_length": result2.object.name.length,
|
|
3463
|
+
"generation.description_length": result2.object.description.length,
|
|
3464
|
+
"generation.attempts": attempt
|
|
3465
|
+
});
|
|
3466
|
+
generationSpan.setStatus({ code: api.SpanStatusCode.OK });
|
|
3467
|
+
return result2;
|
|
3468
|
+
} catch (error) {
|
|
3469
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
3470
|
+
logger8.warn(
|
|
3471
|
+
{
|
|
3472
|
+
sessionId: this.sessionId,
|
|
3473
|
+
artifactId: artifactData.artifactId,
|
|
3474
|
+
attempt,
|
|
3475
|
+
maxRetries,
|
|
3476
|
+
error: lastError.message
|
|
3477
|
+
},
|
|
3478
|
+
`Artifact name/description generation failed, attempt ${attempt}/${maxRetries}`
|
|
3479
|
+
);
|
|
3480
|
+
if (attempt < maxRetries) {
|
|
3481
|
+
const backoffMs = Math.min(1e3 * 2 ** (attempt - 1), 1e4);
|
|
3482
|
+
await new Promise((resolve) => setTimeout(resolve, backoffMs));
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
agentsCore.setSpanWithError(generationSpan, lastError);
|
|
3487
|
+
throw new Error(
|
|
3488
|
+
`Artifact name/description generation failed after ${maxRetries} attempts: ${lastError?.message}`
|
|
3489
|
+
);
|
|
3490
|
+
}
|
|
3491
|
+
);
|
|
3492
|
+
result = object;
|
|
3493
|
+
}
|
|
3438
3494
|
const artifactService = new ArtifactService({
|
|
3439
3495
|
tenantId: artifactData.tenantId,
|
|
3440
3496
|
projectId: artifactData.projectId,
|
|
@@ -3691,8 +3747,10 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3691
3747
|
__publicField(this, "lastStreamedComponents", /* @__PURE__ */ new Map());
|
|
3692
3748
|
__publicField(this, "componentSnapshots", /* @__PURE__ */ new Map());
|
|
3693
3749
|
__publicField(this, "artifactMap");
|
|
3750
|
+
__publicField(this, "agentId");
|
|
3694
3751
|
this.streamHelper = streamHelper;
|
|
3695
3752
|
this.contextId = contextId;
|
|
3753
|
+
this.agentId = artifactParserOptions?.agentId;
|
|
3696
3754
|
if (artifactParserOptions?.streamRequestId) {
|
|
3697
3755
|
const sessionParser = graphSessionManager.getArtifactParser(
|
|
3698
3756
|
artifactParserOptions.streamRequestId
|
|
@@ -3821,7 +3879,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3821
3879
|
async streamComponent(component) {
|
|
3822
3880
|
const parts = await this.artifactParser.parseObject({
|
|
3823
3881
|
dataComponents: [component]
|
|
3824
|
-
});
|
|
3882
|
+
}, this.artifactMap, this.agentId);
|
|
3825
3883
|
if (!Array.isArray(parts)) {
|
|
3826
3884
|
console.warn("parseObject returned non-array:", parts);
|
|
3827
3885
|
return;
|
|
@@ -3893,7 +3951,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3893
3951
|
if (!hasBeenStreamed && this.isComponentComplete(component) && component.name !== "Text") {
|
|
3894
3952
|
const parts = await this.artifactParser.parseObject({
|
|
3895
3953
|
dataComponents: [component]
|
|
3896
|
-
});
|
|
3954
|
+
}, this.artifactMap, this.agentId);
|
|
3897
3955
|
for (const part of parts) {
|
|
3898
3956
|
await this.streamPart(part);
|
|
3899
3957
|
}
|
|
@@ -3946,7 +4004,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3946
4004
|
const safeEnd = this.artifactParser.findSafeTextBoundary(workingBuffer);
|
|
3947
4005
|
if (safeEnd > 0) {
|
|
3948
4006
|
const safeText = workingBuffer.slice(0, safeEnd);
|
|
3949
|
-
const parts2 = await this.artifactParser.parseText(safeText, this.artifactMap);
|
|
4007
|
+
const parts2 = await this.artifactParser.parseText(safeText, this.artifactMap, this.agentId);
|
|
3950
4008
|
completeParts.push(...parts2);
|
|
3951
4009
|
return {
|
|
3952
4010
|
completeParts,
|
|
@@ -3958,7 +4016,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3958
4016
|
remainingBuffer: workingBuffer
|
|
3959
4017
|
};
|
|
3960
4018
|
}
|
|
3961
|
-
const parts = await this.artifactParser.parseText(workingBuffer, this.artifactMap);
|
|
4019
|
+
const parts = await this.artifactParser.parseText(workingBuffer, this.artifactMap, this.agentId);
|
|
3962
4020
|
if (parts.length > 0 && parts[parts.length - 1].kind === "text") {
|
|
3963
4021
|
const lastPart = parts[parts.length - 1];
|
|
3964
4022
|
const lastText = lastPart.text || "";
|
|
@@ -4035,6 +4093,8 @@ var logger10 = agentsCore.getLogger("ResponseFormatter");
|
|
|
4035
4093
|
var ResponseFormatter = class {
|
|
4036
4094
|
constructor(tenantId, artifactParserOptions) {
|
|
4037
4095
|
__publicField(this, "artifactParser");
|
|
4096
|
+
__publicField(this, "agentId");
|
|
4097
|
+
this.agentId = artifactParserOptions?.agentId;
|
|
4038
4098
|
if (artifactParserOptions?.streamRequestId) {
|
|
4039
4099
|
const sessionParser = graphSessionManager.getArtifactParser(artifactParserOptions.streamRequestId);
|
|
4040
4100
|
if (sessionParser) {
|
|
@@ -4055,7 +4115,7 @@ var ResponseFormatter = class {
|
|
|
4055
4115
|
"response.type": "object",
|
|
4056
4116
|
"response.availableArtifacts": artifactMap.size
|
|
4057
4117
|
});
|
|
4058
|
-
const parts = await this.artifactParser.parseObject(responseObject, artifactMap);
|
|
4118
|
+
const parts = await this.artifactParser.parseObject(responseObject, artifactMap, this.agentId);
|
|
4059
4119
|
const uniqueArtifacts = this.countUniqueArtifacts(parts);
|
|
4060
4120
|
span.setAttributes({
|
|
4061
4121
|
"response.dataPartsCount": parts.length,
|
|
@@ -4084,8 +4144,9 @@ var ResponseFormatter = class {
|
|
|
4084
4144
|
async formatResponse(responseText, contextId) {
|
|
4085
4145
|
return tracer.startActiveSpan("response.format_response", async (span) => {
|
|
4086
4146
|
try {
|
|
4147
|
+
const hasMarkers = this.artifactParser.hasArtifactMarkers(responseText);
|
|
4087
4148
|
span.setAttributes({
|
|
4088
|
-
"response.hasArtifactMarkers":
|
|
4149
|
+
"response.hasArtifactMarkers": hasMarkers,
|
|
4089
4150
|
"response.contextId": contextId,
|
|
4090
4151
|
"response.textLength": responseText.length
|
|
4091
4152
|
});
|
|
@@ -4100,7 +4161,7 @@ var ResponseFormatter = class {
|
|
|
4100
4161
|
"response.type": "text",
|
|
4101
4162
|
"response.availableArtifacts": artifactMap.size
|
|
4102
4163
|
});
|
|
4103
|
-
const parts = await this.artifactParser.parseText(responseText, artifactMap);
|
|
4164
|
+
const parts = await this.artifactParser.parseText(responseText, artifactMap, this.agentId);
|
|
4104
4165
|
if (parts.length === 1 && parts[0].kind === "text") {
|
|
4105
4166
|
return { text: parts[0].text };
|
|
4106
4167
|
}
|
|
@@ -5567,6 +5628,14 @@ CITATION PLACEMENT RULES:
|
|
|
5567
5628
|
|
|
5568
5629
|
\u{1F3AF} **KEY PRINCIPLE**: Information from tools \u2192 Complete thought \u2192 Punctuation \u2192 Citation \u2192 Continue
|
|
5569
5630
|
|
|
5631
|
+
DELEGATION AND ARTIFACTS:
|
|
5632
|
+
When you use delegation tools, the response may include artifacts in the parts array. These appear as objects with:
|
|
5633
|
+
- kind: "data"
|
|
5634
|
+
- data: { artifactId, toolCallId, name, description, type, artifactSummary }
|
|
5635
|
+
|
|
5636
|
+
These artifacts become immediately available for you to reference using the artifactId and toolCallId from the response.
|
|
5637
|
+
Present delegation results naturally without mentioning the delegation process itself.
|
|
5638
|
+
|
|
5570
5639
|
IMPORTANT: All agents can retrieve and use information from existing artifacts when the graph has artifact components, regardless of whether the individual agent can create new artifacts.`;
|
|
5571
5640
|
|
|
5572
5641
|
// templates/v1/phase1/system-prompt.xml?raw
|
|
@@ -5605,6 +5674,20 @@ var system_prompt_default = `<system_message>
|
|
|
5605
5674
|
- Save important tool results as artifacts when they contain structured data that should be preserved and referenced
|
|
5606
5675
|
- Ask for clarification when requests are ambiguous
|
|
5607
5676
|
|
|
5677
|
+
\u{1F6A8} UNIFIED ASSISTANT PRESENTATION - CRITICAL:
|
|
5678
|
+
- You are the ONLY assistant the user is interacting with
|
|
5679
|
+
- NEVER mention other agents, specialists, experts, or team members
|
|
5680
|
+
- NEVER use phrases like "I'll delegate", "I'll transfer", "I'll ask our specialist"
|
|
5681
|
+
- NEVER say "the weather agent returned" or "the search specialist found"
|
|
5682
|
+
- Present ALL results as if YOU personally performed the work
|
|
5683
|
+
- Use first person: "I found", "I analyzed", "I've gathered"
|
|
5684
|
+
|
|
5685
|
+
\u{1F6A8} DELEGATION TOOL RULES - CRITICAL:
|
|
5686
|
+
- When using delegate_to_* tools, treat them like any other tool
|
|
5687
|
+
- Present results naturally: "I've analyzed the data and found..."
|
|
5688
|
+
- NEVER mention delegation occurred: just present the results
|
|
5689
|
+
- If delegation returns artifacts, reference them as if you created them
|
|
5690
|
+
|
|
5608
5691
|
\u{1F6A8} TRANSFER TOOL RULES - CRITICAL:
|
|
5609
5692
|
- When calling transfer_to_* tools, call the tool IMMEDIATELY without any explanatory text
|
|
5610
5693
|
- Do NOT explain the transfer, do NOT say "I'll hand this off", do NOT provide reasoning
|
|
@@ -5672,6 +5755,8 @@ var thinking_preparation_default = `<thinking_preparation_mode>
|
|
|
5672
5755
|
var tool_default = "<tool>\n <name>{{TOOL_NAME}}</name>\n <description>{{TOOL_DESCRIPTION}}</description>\n <parameters>\n <schema>\n {{TOOL_PARAMETERS_SCHEMA}}\n </schema>\n </parameters>\n <usage_guidelines>\n {{TOOL_USAGE_GUIDELINES}}\n </usage_guidelines>\n</tool> ";
|
|
5673
5756
|
|
|
5674
5757
|
// src/agents/versions/v1/Phase1Config.ts
|
|
5758
|
+
init_logger();
|
|
5759
|
+
agentsCore.getLogger("Phase1Config");
|
|
5675
5760
|
var Phase1Config = class _Phase1Config {
|
|
5676
5761
|
loadTemplates() {
|
|
5677
5762
|
const templates = /* @__PURE__ */ new Map();
|
|
@@ -5764,13 +5849,18 @@ var Phase1Config = class _Phase1Config {
|
|
|
5764
5849
|
if (!hasTransferRelations) {
|
|
5765
5850
|
return "";
|
|
5766
5851
|
}
|
|
5767
|
-
return
|
|
5852
|
+
return `- You have transfer_to_* tools that seamlessly continue the conversation
|
|
5853
|
+
- NEVER announce transfers - just call the tool when needed
|
|
5854
|
+
- The conversation continues naturally without any handoff language`;
|
|
5768
5855
|
}
|
|
5769
5856
|
generateDelegationInstructions(hasDelegateRelations) {
|
|
5770
5857
|
if (!hasDelegateRelations) {
|
|
5771
5858
|
return "";
|
|
5772
5859
|
}
|
|
5773
|
-
return
|
|
5860
|
+
return `- You have delegate_to_* tools that perform specialized tasks
|
|
5861
|
+
- Treat these exactly like other tools - call them to get results
|
|
5862
|
+
- Present results as YOUR work: "I found", "I've analyzed"
|
|
5863
|
+
- NEVER say you're delegating or that another agent helped`;
|
|
5774
5864
|
}
|
|
5775
5865
|
getArtifactCreationGuidance() {
|
|
5776
5866
|
return `\u{1F6A8} MANDATORY ARTIFACT CREATION \u{1F6A8}
|
|
@@ -5947,10 +6037,16 @@ The implementation details show that you need to register your application first
|
|
|
5947
6037
|
|
|
5948
6038
|
For error handling, you can refer to the comprehensive error documentation. <artifact:ref id='existing-error-doc' tool='call_previous012' /> This lists all possible authentication errors and their solutions."
|
|
5949
6039
|
|
|
6040
|
+
EXAMPLE REFERENCING DELEGATION ARTIFACTS:
|
|
6041
|
+
After receiving a delegation response with artifacts, reference them naturally:
|
|
6042
|
+
|
|
6043
|
+
"I've gathered the requested data for you. The analysis <artifact:ref id='analysis-results' tool='toolu_abc123' /> shows significant improvements across all metrics.
|
|
6044
|
+
|
|
6045
|
+
Looking at the detailed breakdown <artifact:ref id='performance-metrics' tool='toolu_def456' />, the processing time has decreased by 40% while maintaining accuracy."
|
|
6046
|
+
|
|
5950
6047
|
IMPORTANT GUIDELINES:
|
|
5951
|
-
- You can only reference artifacts that already exist
|
|
5952
|
-
- Use artifact:ref annotations in your text
|
|
5953
|
-
- Copy artifact_id and tool_call_id exactly from existing artifacts
|
|
6048
|
+
- You can only reference artifacts that already exist or were returned from delegations
|
|
6049
|
+
- Use artifact:ref annotations in your text with the exact artifactId and toolCallId
|
|
5954
6050
|
- References are automatically converted to interactive elements`;
|
|
5955
6051
|
}
|
|
5956
6052
|
return "";
|
|
@@ -6091,7 +6187,43 @@ ${propertiesXml}
|
|
|
6091
6187
|
};
|
|
6092
6188
|
|
|
6093
6189
|
// templates/v1/phase2/system-prompt.xml?raw
|
|
6094
|
-
var system_prompt_default2 =
|
|
6190
|
+
var system_prompt_default2 = `<phase2_system_message>
|
|
6191
|
+
<instruction>
|
|
6192
|
+
Generate the final structured JSON response using the configured data components and artifact creation capabilities.
|
|
6193
|
+
</instruction>
|
|
6194
|
+
|
|
6195
|
+
<core_instructions>
|
|
6196
|
+
{{CORE_INSTRUCTIONS}}
|
|
6197
|
+
</core_instructions>
|
|
6198
|
+
|
|
6199
|
+
{{ARTIFACTS_SECTION}}
|
|
6200
|
+
{{DATA_COMPONENTS_SECTION}}
|
|
6201
|
+
|
|
6202
|
+
{{ARTIFACT_GUIDANCE_SECTION}}
|
|
6203
|
+
|
|
6204
|
+
{{ARTIFACT_TYPES_SECTION}}
|
|
6205
|
+
|
|
6206
|
+
<requirements>
|
|
6207
|
+
<key_requirements>
|
|
6208
|
+
- Create artifacts from tool results to support your information with citations
|
|
6209
|
+
- Mix artifact creation and references naturally throughout your dataComponents array
|
|
6210
|
+
- Each artifact creation must use EXACT tool_call_id from tool outputs
|
|
6211
|
+
- Use appropriate ArtifactCreate_[Type] components for each artifact type
|
|
6212
|
+
- IMPORTANT: In Text components, write naturally as if having a conversation - do NOT mention components, schemas, JSON, structured data, or any technical implementation details
|
|
6213
|
+
</key_requirements>
|
|
6214
|
+
|
|
6215
|
+
<unified_presentation>
|
|
6216
|
+
\u{1F6A8} CRITICAL - PRESENT AS ONE UNIFIED ASSISTANT:
|
|
6217
|
+
- You are the ONLY assistant in this conversation
|
|
6218
|
+
- NEVER reference other agents, specialists, or team members
|
|
6219
|
+
- All tool results (including delegate_to_* tools) are YOUR findings
|
|
6220
|
+
- Present delegation results as: "I found", "I've analyzed", "The data shows"
|
|
6221
|
+
- NEVER say: "The specialist returned", "Another agent found", "I delegated this"
|
|
6222
|
+
- Artifacts from delegation are YOUR artifacts - reference them naturally
|
|
6223
|
+
- Maintain consistent first-person perspective throughout
|
|
6224
|
+
</unified_presentation>
|
|
6225
|
+
</requirements>
|
|
6226
|
+
</phase2_system_message>`;
|
|
6095
6227
|
|
|
6096
6228
|
// templates/v1/phase2/data-components.xml?raw
|
|
6097
6229
|
var data_components_default = '<data_components_section description="These are the data components available for you to use in generating responses. Each component represents a single structured piece of information. You can create multiple instances of the same component type when needed.\n\n***MANDATORY JSON RESPONSE FORMAT - ABSOLUTELY CRITICAL***:\n- WHEN DATA COMPONENTS ARE AVAILABLE, YOU MUST RESPOND IN JSON FORMAT ONLY\n- DO NOT respond with plain text when data components are defined\n- YOUR RESPONSE MUST BE STRUCTURED JSON WITH dataComponents ARRAY\n- THIS IS NON-NEGOTIABLE - JSON FORMAT IS REQUIRED\n\nCRITICAL JSON FORMATTING RULES - MUST FOLLOW EXACTLY:\n1. Each data component must include id, name, and props fields\n2. The id and name should match the exact component definition\n3. The props field contains the actual component data using exact property names from the schema\n4. NEVER omit the id and name fields\n\nCORRECT: [{\\"id\\": \\"component1\\", \\"name\\": \\"Component1\\", \\"props\\": {\\"field1\\": \\"value1\\", \\"field2\\": \\"value2\\"}}, {\\"id\\": \\"component2\\", \\"name\\": \\"Component2\\", \\"props\\": {\\"field3\\": \\"value3\\"}}]\nWRONG: [{\\"field1\\": \\"value1\\", \\"field2\\": \\"value2\\"}, {\\"field3\\": \\"value3\\"}]\n\nAVAILABLE DATA COMPONENTS: {{DATA_COMPONENTS_LIST}}">\n\n{{DATA_COMPONENTS_XML}}\n\n</data_components_section>';
|
|
@@ -6200,8 +6332,11 @@ COMMON FAILURE POINTS (AVOID THESE):
|
|
|
6200
6332
|
if (!shouldShowReferencingRules) {
|
|
6201
6333
|
return "";
|
|
6202
6334
|
}
|
|
6335
|
+
const sharedGuidance = artifact_retrieval_guidance_default;
|
|
6203
6336
|
if (hasArtifactComponents && artifactComponents && artifactComponents.length > 0) {
|
|
6204
|
-
return
|
|
6337
|
+
return `${sharedGuidance}
|
|
6338
|
+
|
|
6339
|
+
ARTIFACT MANAGEMENT FOR STRUCTURED RESPONSES:
|
|
6205
6340
|
|
|
6206
6341
|
You will create and reference artifacts using data components in your JSON response.
|
|
6207
6342
|
|
|
@@ -6281,12 +6416,14 @@ COMPONENT GUIDELINES:
|
|
|
6281
6416
|
- Only add Artifact reference components when citing the SAME artifact again for a different point
|
|
6282
6417
|
- Use tool_call_id exactly as it appears in tool execution results`;
|
|
6283
6418
|
}
|
|
6284
|
-
return
|
|
6419
|
+
return `${sharedGuidance}
|
|
6420
|
+
|
|
6421
|
+
ARTIFACT REFERENCING FOR STRUCTURED RESPONSES:
|
|
6285
6422
|
|
|
6286
6423
|
You can reference existing artifacts but cannot create new ones.
|
|
6287
6424
|
|
|
6288
6425
|
HOW TO REFERENCE ARTIFACTS:
|
|
6289
|
-
Use the Artifact component with artifact_id and tool_call_id from existing artifacts.
|
|
6426
|
+
Use the Artifact component with artifact_id and tool_call_id from existing artifacts or delegation responses.
|
|
6290
6427
|
|
|
6291
6428
|
EXAMPLE STRUCTURED RESPONSE:
|
|
6292
6429
|
\`\`\`json
|
|
@@ -6460,7 +6597,7 @@ function hasToolCallWithPrefix(prefix) {
|
|
|
6460
6597
|
return false;
|
|
6461
6598
|
};
|
|
6462
6599
|
}
|
|
6463
|
-
var
|
|
6600
|
+
var logger16 = agentsCore.getLogger("Agent");
|
|
6464
6601
|
var CONSTANTS = {
|
|
6465
6602
|
MAX_GENERATION_STEPS: 12,
|
|
6466
6603
|
PHASE_1_TIMEOUT_MS: 27e4,
|
|
@@ -6759,14 +6896,14 @@ var Agent = class {
|
|
|
6759
6896
|
for (const toolSet of tools) {
|
|
6760
6897
|
for (const [toolName, originalTool] of Object.entries(toolSet)) {
|
|
6761
6898
|
if (!isValidTool(originalTool)) {
|
|
6762
|
-
|
|
6899
|
+
logger16.error({ toolName }, "Invalid MCP tool structure - missing required properties");
|
|
6763
6900
|
continue;
|
|
6764
6901
|
}
|
|
6765
6902
|
const sessionWrappedTool = ai.tool({
|
|
6766
6903
|
description: originalTool.description,
|
|
6767
6904
|
inputSchema: originalTool.inputSchema,
|
|
6768
6905
|
execute: async (args, { toolCallId }) => {
|
|
6769
|
-
|
|
6906
|
+
logger16.debug({ toolName, toolCallId }, "MCP Tool Called");
|
|
6770
6907
|
try {
|
|
6771
6908
|
const rawResult = await originalTool.execute(args, { toolCallId });
|
|
6772
6909
|
const parsedResult = parseEmbeddedJson(rawResult);
|
|
@@ -6780,7 +6917,7 @@ var Agent = class {
|
|
|
6780
6917
|
});
|
|
6781
6918
|
return { result: enhancedResult, toolCallId };
|
|
6782
6919
|
} catch (error) {
|
|
6783
|
-
|
|
6920
|
+
logger16.error({ toolName, toolCallId, error }, "MCP tool execution failed");
|
|
6784
6921
|
throw error;
|
|
6785
6922
|
}
|
|
6786
6923
|
}
|
|
@@ -6874,7 +7011,7 @@ var Agent = class {
|
|
|
6874
7011
|
headers: agentToolRelationHeaders
|
|
6875
7012
|
};
|
|
6876
7013
|
}
|
|
6877
|
-
|
|
7014
|
+
logger16.info(
|
|
6878
7015
|
{
|
|
6879
7016
|
toolName: tool3.name,
|
|
6880
7017
|
credentialReferenceId,
|
|
@@ -6914,7 +7051,7 @@ var Agent = class {
|
|
|
6914
7051
|
async getResolvedContext(conversationId, requestContext) {
|
|
6915
7052
|
try {
|
|
6916
7053
|
if (!this.config.contextConfigId) {
|
|
6917
|
-
|
|
7054
|
+
logger16.debug({ graphId: this.config.graphId }, "No context config found for graph");
|
|
6918
7055
|
return null;
|
|
6919
7056
|
}
|
|
6920
7057
|
const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
|
|
@@ -6922,7 +7059,7 @@ var Agent = class {
|
|
|
6922
7059
|
id: this.config.contextConfigId
|
|
6923
7060
|
});
|
|
6924
7061
|
if (!contextConfig) {
|
|
6925
|
-
|
|
7062
|
+
logger16.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
|
|
6926
7063
|
return null;
|
|
6927
7064
|
}
|
|
6928
7065
|
if (!this.contextResolver) {
|
|
@@ -6939,7 +7076,7 @@ var Agent = class {
|
|
|
6939
7076
|
$now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6940
7077
|
$env: process.env
|
|
6941
7078
|
};
|
|
6942
|
-
|
|
7079
|
+
logger16.debug(
|
|
6943
7080
|
{
|
|
6944
7081
|
conversationId,
|
|
6945
7082
|
contextConfigId: contextConfig.id,
|
|
@@ -6953,7 +7090,7 @@ var Agent = class {
|
|
|
6953
7090
|
);
|
|
6954
7091
|
return contextWithBuiltins;
|
|
6955
7092
|
} catch (error) {
|
|
6956
|
-
|
|
7093
|
+
logger16.error(
|
|
6957
7094
|
{
|
|
6958
7095
|
conversationId,
|
|
6959
7096
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -6977,7 +7114,7 @@ var Agent = class {
|
|
|
6977
7114
|
});
|
|
6978
7115
|
return graphDefinition?.graphPrompt || void 0;
|
|
6979
7116
|
} catch (error) {
|
|
6980
|
-
|
|
7117
|
+
logger16.warn(
|
|
6981
7118
|
{
|
|
6982
7119
|
graphId: this.config.graphId,
|
|
6983
7120
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -7006,7 +7143,7 @@ var Agent = class {
|
|
|
7006
7143
|
(agent) => "artifactComponents" in agent && agent.artifactComponents && agent.artifactComponents.length > 0
|
|
7007
7144
|
);
|
|
7008
7145
|
} catch (error) {
|
|
7009
|
-
|
|
7146
|
+
logger16.warn(
|
|
7010
7147
|
{
|
|
7011
7148
|
graphId: this.config.graphId,
|
|
7012
7149
|
tenantId: this.config.tenantId,
|
|
@@ -7035,7 +7172,7 @@ var Agent = class {
|
|
|
7035
7172
|
preserveUnresolved: false
|
|
7036
7173
|
});
|
|
7037
7174
|
} catch (error) {
|
|
7038
|
-
|
|
7175
|
+
logger16.error(
|
|
7039
7176
|
{
|
|
7040
7177
|
conversationId,
|
|
7041
7178
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -7082,7 +7219,7 @@ var Agent = class {
|
|
|
7082
7219
|
preserveUnresolved: false
|
|
7083
7220
|
});
|
|
7084
7221
|
} catch (error) {
|
|
7085
|
-
|
|
7222
|
+
logger16.error(
|
|
7086
7223
|
{
|
|
7087
7224
|
conversationId,
|
|
7088
7225
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -7121,7 +7258,7 @@ var Agent = class {
|
|
|
7121
7258
|
preserveUnresolved: false
|
|
7122
7259
|
});
|
|
7123
7260
|
} catch (error) {
|
|
7124
|
-
|
|
7261
|
+
logger16.error(
|
|
7125
7262
|
{
|
|
7126
7263
|
conversationId,
|
|
7127
7264
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -7153,7 +7290,7 @@ var Agent = class {
|
|
|
7153
7290
|
artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
|
|
7154
7291
|
}),
|
|
7155
7292
|
execute: async ({ artifactId }) => {
|
|
7156
|
-
|
|
7293
|
+
logger16.info({ artifactId }, "get_artifact executed");
|
|
7157
7294
|
const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
|
|
7158
7295
|
scopes: {
|
|
7159
7296
|
tenantId: this.config.tenantId,
|
|
@@ -7403,7 +7540,7 @@ var Agent = class {
|
|
|
7403
7540
|
};
|
|
7404
7541
|
return enhanced;
|
|
7405
7542
|
} catch (error) {
|
|
7406
|
-
|
|
7543
|
+
logger16.warn({ error }, "Failed to enhance tool result with structure hints");
|
|
7407
7544
|
return result;
|
|
7408
7545
|
}
|
|
7409
7546
|
}
|
|
@@ -7418,7 +7555,7 @@ var Agent = class {
|
|
|
7418
7555
|
}
|
|
7419
7556
|
});
|
|
7420
7557
|
} catch (error) {
|
|
7421
|
-
|
|
7558
|
+
logger16.error(
|
|
7422
7559
|
{ error, graphId: this.config.graphId },
|
|
7423
7560
|
"Failed to check graph artifact components"
|
|
7424
7561
|
);
|
|
@@ -7518,7 +7655,7 @@ var Agent = class {
|
|
|
7518
7655
|
const configuredTimeout = modelSettings.maxDuration ? Math.min(modelSettings.maxDuration * 1e3, MAX_ALLOWED_TIMEOUT_MS) : shouldStreamPhase1 ? CONSTANTS.PHASE_1_TIMEOUT_MS : CONSTANTS.NON_STREAMING_PHASE_1_TIMEOUT_MS;
|
|
7519
7656
|
const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
|
|
7520
7657
|
if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
|
|
7521
|
-
|
|
7658
|
+
logger16.warn(
|
|
7522
7659
|
{
|
|
7523
7660
|
requestedTimeout: modelSettings.maxDuration * 1e3,
|
|
7524
7661
|
appliedTimeout: timeoutMs,
|
|
@@ -7560,7 +7697,7 @@ var Agent = class {
|
|
|
7560
7697
|
}
|
|
7561
7698
|
);
|
|
7562
7699
|
} catch (error) {
|
|
7563
|
-
|
|
7700
|
+
logger16.debug({ error }, "Failed to track agent reasoning");
|
|
7564
7701
|
}
|
|
7565
7702
|
}
|
|
7566
7703
|
if (last && "toolCalls" in last && last.toolCalls) {
|
|
@@ -7657,7 +7794,7 @@ var Agent = class {
|
|
|
7657
7794
|
}
|
|
7658
7795
|
);
|
|
7659
7796
|
} catch (error) {
|
|
7660
|
-
|
|
7797
|
+
logger16.debug({ error }, "Failed to track agent reasoning");
|
|
7661
7798
|
}
|
|
7662
7799
|
}
|
|
7663
7800
|
if (last && "toolCalls" in last && last.toolCalls) {
|
|
@@ -7948,7 +8085,7 @@ ${output}${structureHintsFormatted}`;
|
|
|
7948
8085
|
};
|
|
7949
8086
|
|
|
7950
8087
|
// src/agents/generateTaskHandler.ts
|
|
7951
|
-
var
|
|
8088
|
+
var logger17 = agentsCore.getLogger("generateTaskHandler");
|
|
7952
8089
|
var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
7953
8090
|
return async (task) => {
|
|
7954
8091
|
try {
|
|
@@ -8001,7 +8138,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8001
8138
|
}
|
|
8002
8139
|
})
|
|
8003
8140
|
]);
|
|
8004
|
-
|
|
8141
|
+
logger17.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
|
|
8005
8142
|
const enhancedInternalRelations = await Promise.all(
|
|
8006
8143
|
internalRelations.map(async (relation) => {
|
|
8007
8144
|
try {
|
|
@@ -8030,7 +8167,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8030
8167
|
return { ...relation, description: enhancedDescription };
|
|
8031
8168
|
}
|
|
8032
8169
|
} catch (error) {
|
|
8033
|
-
|
|
8170
|
+
logger17.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
|
|
8034
8171
|
}
|
|
8035
8172
|
return relation;
|
|
8036
8173
|
})
|
|
@@ -8130,7 +8267,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8130
8267
|
const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
|
|
8131
8268
|
if (taskIdMatch) {
|
|
8132
8269
|
contextId = taskIdMatch[1];
|
|
8133
|
-
|
|
8270
|
+
logger17.info(
|
|
8134
8271
|
{
|
|
8135
8272
|
taskId: task.id,
|
|
8136
8273
|
extractedContextId: contextId,
|
|
@@ -8146,7 +8283,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8146
8283
|
const isDelegation = task.context?.metadata?.isDelegation === true;
|
|
8147
8284
|
agent.setDelegationStatus(isDelegation);
|
|
8148
8285
|
if (isDelegation) {
|
|
8149
|
-
|
|
8286
|
+
logger17.info(
|
|
8150
8287
|
{ agentId: config.agentId, taskId: task.id },
|
|
8151
8288
|
"Delegated agent - streaming disabled"
|
|
8152
8289
|
);
|
|
@@ -8371,7 +8508,7 @@ async function getRegisteredGraph(executionContext) {
|
|
|
8371
8508
|
init_dbClient();
|
|
8372
8509
|
init_logger();
|
|
8373
8510
|
var app = new zodOpenapi.OpenAPIHono();
|
|
8374
|
-
var
|
|
8511
|
+
var logger18 = agentsCore.getLogger("agents");
|
|
8375
8512
|
app.openapi(
|
|
8376
8513
|
zodOpenapi.createRoute({
|
|
8377
8514
|
method: "get",
|
|
@@ -8409,7 +8546,7 @@ app.openapi(
|
|
|
8409
8546
|
tracestate: c.req.header("tracestate"),
|
|
8410
8547
|
baggage: c.req.header("baggage")
|
|
8411
8548
|
};
|
|
8412
|
-
|
|
8549
|
+
logger18.info(
|
|
8413
8550
|
{
|
|
8414
8551
|
otelHeaders,
|
|
8415
8552
|
path: c.req.path,
|
|
@@ -8421,7 +8558,7 @@ app.openapi(
|
|
|
8421
8558
|
const { tenantId, projectId, graphId, agentId } = executionContext;
|
|
8422
8559
|
console.dir("executionContext", executionContext);
|
|
8423
8560
|
if (agentId) {
|
|
8424
|
-
|
|
8561
|
+
logger18.info(
|
|
8425
8562
|
{
|
|
8426
8563
|
message: "getRegisteredAgent (agent-level)",
|
|
8427
8564
|
tenantId,
|
|
@@ -8433,7 +8570,7 @@ app.openapi(
|
|
|
8433
8570
|
);
|
|
8434
8571
|
const credentialStores = c.get("credentialStores");
|
|
8435
8572
|
const agent = await getRegisteredAgent(executionContext, credentialStores);
|
|
8436
|
-
|
|
8573
|
+
logger18.info({ agent }, "agent registered: well-known agent.json");
|
|
8437
8574
|
if (!agent) {
|
|
8438
8575
|
throw agentsCore.createApiError({
|
|
8439
8576
|
code: "not_found",
|
|
@@ -8442,7 +8579,7 @@ app.openapi(
|
|
|
8442
8579
|
}
|
|
8443
8580
|
return c.json(agent.agentCard);
|
|
8444
8581
|
} else {
|
|
8445
|
-
|
|
8582
|
+
logger18.info(
|
|
8446
8583
|
{
|
|
8447
8584
|
message: "getRegisteredGraph (graph-level)",
|
|
8448
8585
|
tenantId,
|
|
@@ -8468,7 +8605,7 @@ app.post("/a2a", async (c) => {
|
|
|
8468
8605
|
tracestate: c.req.header("tracestate"),
|
|
8469
8606
|
baggage: c.req.header("baggage")
|
|
8470
8607
|
};
|
|
8471
|
-
|
|
8608
|
+
logger18.info(
|
|
8472
8609
|
{
|
|
8473
8610
|
otelHeaders,
|
|
8474
8611
|
path: c.req.path,
|
|
@@ -8479,7 +8616,7 @@ app.post("/a2a", async (c) => {
|
|
|
8479
8616
|
const executionContext = agentsCore.getRequestExecutionContext(c);
|
|
8480
8617
|
const { tenantId, projectId, graphId, agentId } = executionContext;
|
|
8481
8618
|
if (agentId) {
|
|
8482
|
-
|
|
8619
|
+
logger18.info(
|
|
8483
8620
|
{
|
|
8484
8621
|
message: "a2a (agent-level)",
|
|
8485
8622
|
tenantId,
|
|
@@ -8503,7 +8640,7 @@ app.post("/a2a", async (c) => {
|
|
|
8503
8640
|
}
|
|
8504
8641
|
return a2aHandler(c, agent);
|
|
8505
8642
|
} else {
|
|
8506
|
-
|
|
8643
|
+
logger18.info(
|
|
8507
8644
|
{
|
|
8508
8645
|
message: "a2a (graph-level)",
|
|
8509
8646
|
tenantId,
|
|
@@ -8559,14 +8696,14 @@ init_dbClient();
|
|
|
8559
8696
|
// src/a2a/transfer.ts
|
|
8560
8697
|
init_dbClient();
|
|
8561
8698
|
init_logger();
|
|
8562
|
-
var
|
|
8699
|
+
var logger19 = agentsCore.getLogger("Transfer");
|
|
8563
8700
|
async function executeTransfer({
|
|
8564
8701
|
tenantId,
|
|
8565
8702
|
threadId,
|
|
8566
8703
|
projectId,
|
|
8567
8704
|
targetAgentId
|
|
8568
8705
|
}) {
|
|
8569
|
-
|
|
8706
|
+
logger19.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
|
|
8570
8707
|
await agentsCore.setActiveAgentForThread(dbClient_default)({
|
|
8571
8708
|
scopes: { tenantId, projectId },
|
|
8572
8709
|
threadId,
|
|
@@ -9152,7 +9289,7 @@ function createMCPStreamHelper() {
|
|
|
9152
9289
|
}
|
|
9153
9290
|
|
|
9154
9291
|
// src/handlers/executionHandler.ts
|
|
9155
|
-
var
|
|
9292
|
+
var logger20 = agentsCore.getLogger("ExecutionHandler");
|
|
9156
9293
|
var ExecutionHandler = class {
|
|
9157
9294
|
constructor() {
|
|
9158
9295
|
// Hardcoded error limit - separate from configurable stopWhen
|
|
@@ -9177,7 +9314,7 @@ var ExecutionHandler = class {
|
|
|
9177
9314
|
const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
|
|
9178
9315
|
registerStreamHelper(requestId2, sseHelper);
|
|
9179
9316
|
graphSessionManager.createSession(requestId2, graphId, tenantId, projectId, conversationId);
|
|
9180
|
-
|
|
9317
|
+
logger20.info(
|
|
9181
9318
|
{ sessionId: requestId2, graphId, conversationId },
|
|
9182
9319
|
"Created GraphSession for message execution"
|
|
9183
9320
|
);
|
|
@@ -9192,7 +9329,7 @@ var ExecutionHandler = class {
|
|
|
9192
9329
|
);
|
|
9193
9330
|
}
|
|
9194
9331
|
} catch (error) {
|
|
9195
|
-
|
|
9332
|
+
logger20.error(
|
|
9196
9333
|
{
|
|
9197
9334
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
9198
9335
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -9208,7 +9345,7 @@ var ExecutionHandler = class {
|
|
|
9208
9345
|
try {
|
|
9209
9346
|
await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
|
|
9210
9347
|
const taskId = `task_${conversationId}-${requestId2}`;
|
|
9211
|
-
|
|
9348
|
+
logger20.info(
|
|
9212
9349
|
{ taskId, currentAgentId, conversationId, requestId: requestId2 },
|
|
9213
9350
|
"Attempting to create or reuse existing task"
|
|
9214
9351
|
);
|
|
@@ -9232,7 +9369,7 @@ var ExecutionHandler = class {
|
|
|
9232
9369
|
agent_id: currentAgentId
|
|
9233
9370
|
}
|
|
9234
9371
|
});
|
|
9235
|
-
|
|
9372
|
+
logger20.info(
|
|
9236
9373
|
{
|
|
9237
9374
|
taskId,
|
|
9238
9375
|
createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
|
|
@@ -9241,27 +9378,27 @@ var ExecutionHandler = class {
|
|
|
9241
9378
|
);
|
|
9242
9379
|
} catch (error) {
|
|
9243
9380
|
if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
|
|
9244
|
-
|
|
9381
|
+
logger20.info(
|
|
9245
9382
|
{ taskId, error: error.message },
|
|
9246
9383
|
"Task already exists, fetching existing task"
|
|
9247
9384
|
);
|
|
9248
9385
|
const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
|
|
9249
9386
|
if (existingTask) {
|
|
9250
9387
|
task = existingTask;
|
|
9251
|
-
|
|
9388
|
+
logger20.info(
|
|
9252
9389
|
{ taskId, existingTask },
|
|
9253
9390
|
"Successfully reused existing task from race condition"
|
|
9254
9391
|
);
|
|
9255
9392
|
} else {
|
|
9256
|
-
|
|
9393
|
+
logger20.error({ taskId, error }, "Task constraint failed but task not found");
|
|
9257
9394
|
throw error;
|
|
9258
9395
|
}
|
|
9259
9396
|
} else {
|
|
9260
|
-
|
|
9397
|
+
logger20.error({ taskId, error }, "Failed to create task due to non-constraint error");
|
|
9261
9398
|
throw error;
|
|
9262
9399
|
}
|
|
9263
9400
|
}
|
|
9264
|
-
|
|
9401
|
+
logger20.debug(
|
|
9265
9402
|
{
|
|
9266
9403
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9267
9404
|
executionType: "create_initial_task",
|
|
@@ -9279,7 +9416,7 @@ var ExecutionHandler = class {
|
|
|
9279
9416
|
const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
|
|
9280
9417
|
while (iterations < maxTransfers) {
|
|
9281
9418
|
iterations++;
|
|
9282
|
-
|
|
9419
|
+
logger20.info(
|
|
9283
9420
|
{ iterations, currentAgentId, graphId, conversationId, fromAgentId },
|
|
9284
9421
|
`Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
|
|
9285
9422
|
);
|
|
@@ -9287,10 +9424,10 @@ var ExecutionHandler = class {
|
|
|
9287
9424
|
scopes: { tenantId, projectId },
|
|
9288
9425
|
conversationId
|
|
9289
9426
|
});
|
|
9290
|
-
|
|
9427
|
+
logger20.info({ activeAgent }, "activeAgent");
|
|
9291
9428
|
if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
|
|
9292
9429
|
currentAgentId = activeAgent.activeAgentId;
|
|
9293
|
-
|
|
9430
|
+
logger20.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
|
|
9294
9431
|
}
|
|
9295
9432
|
const agentBaseUrl = `${baseUrl}/agents`;
|
|
9296
9433
|
const a2aClient = new A2AClient(agentBaseUrl, {
|
|
@@ -9331,13 +9468,13 @@ var ExecutionHandler = class {
|
|
|
9331
9468
|
});
|
|
9332
9469
|
if (!messageResponse?.result) {
|
|
9333
9470
|
errorCount++;
|
|
9334
|
-
|
|
9471
|
+
logger20.error(
|
|
9335
9472
|
{ currentAgentId, iterations, errorCount },
|
|
9336
9473
|
`No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
|
|
9337
9474
|
);
|
|
9338
9475
|
if (errorCount >= this.MAX_ERRORS) {
|
|
9339
9476
|
const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
|
|
9340
|
-
|
|
9477
|
+
logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
|
|
9341
9478
|
await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
|
|
9342
9479
|
if (task) {
|
|
9343
9480
|
await agentsCore.updateTask(dbClient_default)({
|
|
@@ -9362,7 +9499,7 @@ var ExecutionHandler = class {
|
|
|
9362
9499
|
const transferResponse = messageResponse.result;
|
|
9363
9500
|
const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
|
|
9364
9501
|
const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
|
|
9365
|
-
|
|
9502
|
+
logger20.info({ targetAgentId, transferReason }, "transfer response");
|
|
9366
9503
|
currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
|
|
9367
9504
|
const { success, targetAgentId: newAgentId } = await executeTransfer({
|
|
9368
9505
|
projectId,
|
|
@@ -9373,7 +9510,7 @@ var ExecutionHandler = class {
|
|
|
9373
9510
|
if (success) {
|
|
9374
9511
|
fromAgentId = currentAgentId;
|
|
9375
9512
|
currentAgentId = newAgentId;
|
|
9376
|
-
|
|
9513
|
+
logger20.info(
|
|
9377
9514
|
{
|
|
9378
9515
|
transferFrom: fromAgentId,
|
|
9379
9516
|
transferTo: currentAgentId,
|
|
@@ -9391,7 +9528,7 @@ var ExecutionHandler = class {
|
|
|
9391
9528
|
const graphSessionData = graphSessionManager.getSession(requestId2);
|
|
9392
9529
|
if (graphSessionData) {
|
|
9393
9530
|
const sessionSummary = graphSessionData.getSummary();
|
|
9394
|
-
|
|
9531
|
+
logger20.info(sessionSummary, "GraphSession data after completion");
|
|
9395
9532
|
}
|
|
9396
9533
|
let textContent = "";
|
|
9397
9534
|
for (const part of responseParts) {
|
|
@@ -9445,22 +9582,22 @@ var ExecutionHandler = class {
|
|
|
9445
9582
|
}
|
|
9446
9583
|
});
|
|
9447
9584
|
const updateTaskEnd = Date.now();
|
|
9448
|
-
|
|
9585
|
+
logger20.info(
|
|
9449
9586
|
{ duration: updateTaskEnd - updateTaskStart },
|
|
9450
9587
|
"Completed updateTask operation"
|
|
9451
9588
|
);
|
|
9452
9589
|
await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
|
|
9453
9590
|
await sseHelper.complete();
|
|
9454
|
-
|
|
9591
|
+
logger20.info({}, "Ending GraphSession and cleaning up");
|
|
9455
9592
|
graphSessionManager.endSession(requestId2);
|
|
9456
|
-
|
|
9593
|
+
logger20.info({}, "Cleaning up streamHelper");
|
|
9457
9594
|
unregisterStreamHelper(requestId2);
|
|
9458
9595
|
let response;
|
|
9459
9596
|
if (sseHelper instanceof MCPStreamHelper) {
|
|
9460
9597
|
const captured = sseHelper.getCapturedResponse();
|
|
9461
9598
|
response = captured.text || "No response content";
|
|
9462
9599
|
}
|
|
9463
|
-
|
|
9600
|
+
logger20.info({}, "ExecutionHandler returning success");
|
|
9464
9601
|
return { success: true, iterations, response };
|
|
9465
9602
|
} catch (error) {
|
|
9466
9603
|
agentsCore.setSpanWithError(span, error);
|
|
@@ -9471,13 +9608,13 @@ var ExecutionHandler = class {
|
|
|
9471
9608
|
});
|
|
9472
9609
|
}
|
|
9473
9610
|
errorCount++;
|
|
9474
|
-
|
|
9611
|
+
logger20.warn(
|
|
9475
9612
|
{ iterations, errorCount },
|
|
9476
9613
|
`No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
|
|
9477
9614
|
);
|
|
9478
9615
|
if (errorCount >= this.MAX_ERRORS) {
|
|
9479
9616
|
const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
|
|
9480
|
-
|
|
9617
|
+
logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
|
|
9481
9618
|
await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
|
|
9482
9619
|
if (task) {
|
|
9483
9620
|
await agentsCore.updateTask(dbClient_default)({
|
|
@@ -9498,7 +9635,7 @@ var ExecutionHandler = class {
|
|
|
9498
9635
|
}
|
|
9499
9636
|
}
|
|
9500
9637
|
const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
|
|
9501
|
-
|
|
9638
|
+
logger20.error({ maxTransfers, iterations }, errorMessage);
|
|
9502
9639
|
await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
|
|
9503
9640
|
if (task) {
|
|
9504
9641
|
await agentsCore.updateTask(dbClient_default)({
|
|
@@ -9517,7 +9654,7 @@ var ExecutionHandler = class {
|
|
|
9517
9654
|
unregisterStreamHelper(requestId2);
|
|
9518
9655
|
return { success: false, error: errorMessage, iterations };
|
|
9519
9656
|
} catch (error) {
|
|
9520
|
-
|
|
9657
|
+
logger20.error({ error }, "Error in execution handler");
|
|
9521
9658
|
const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
|
|
9522
9659
|
await sseHelper.writeOperation(
|
|
9523
9660
|
errorOp(`Execution error: ${errorMessage}`, currentAgentId || "system")
|
|
@@ -9545,7 +9682,7 @@ var ExecutionHandler = class {
|
|
|
9545
9682
|
// src/routes/chat.ts
|
|
9546
9683
|
init_logger();
|
|
9547
9684
|
var app2 = new zodOpenapi.OpenAPIHono();
|
|
9548
|
-
var
|
|
9685
|
+
var logger21 = agentsCore.getLogger("completionsHandler");
|
|
9549
9686
|
var chatCompletionsRoute = zodOpenapi.createRoute({
|
|
9550
9687
|
method: "post",
|
|
9551
9688
|
path: "/completions",
|
|
@@ -9663,7 +9800,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9663
9800
|
tracestate: c.req.header("tracestate"),
|
|
9664
9801
|
baggage: c.req.header("baggage")
|
|
9665
9802
|
};
|
|
9666
|
-
|
|
9803
|
+
logger21.info(
|
|
9667
9804
|
{
|
|
9668
9805
|
otelHeaders,
|
|
9669
9806
|
path: c.req.path,
|
|
@@ -9756,7 +9893,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9756
9893
|
dbClient: dbClient_default,
|
|
9757
9894
|
credentialStores
|
|
9758
9895
|
});
|
|
9759
|
-
|
|
9896
|
+
logger21.info(
|
|
9760
9897
|
{
|
|
9761
9898
|
tenantId,
|
|
9762
9899
|
projectId,
|
|
@@ -9804,7 +9941,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9804
9941
|
try {
|
|
9805
9942
|
const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
|
|
9806
9943
|
await sseHelper.writeRole();
|
|
9807
|
-
|
|
9944
|
+
logger21.info({ agentId }, "Starting execution");
|
|
9808
9945
|
const executionHandler = new ExecutionHandler();
|
|
9809
9946
|
const result = await executionHandler.execute({
|
|
9810
9947
|
executionContext,
|
|
@@ -9814,7 +9951,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9814
9951
|
requestId: requestId2,
|
|
9815
9952
|
sseHelper
|
|
9816
9953
|
});
|
|
9817
|
-
|
|
9954
|
+
logger21.info(
|
|
9818
9955
|
{ result },
|
|
9819
9956
|
`Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
|
|
9820
9957
|
);
|
|
@@ -9828,7 +9965,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9828
9965
|
}
|
|
9829
9966
|
await sseHelper.complete();
|
|
9830
9967
|
} catch (error) {
|
|
9831
|
-
|
|
9968
|
+
logger21.error(
|
|
9832
9969
|
{
|
|
9833
9970
|
error: error instanceof Error ? error.message : error,
|
|
9834
9971
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -9845,12 +9982,12 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9845
9982
|
);
|
|
9846
9983
|
await sseHelper.complete();
|
|
9847
9984
|
} catch (streamError) {
|
|
9848
|
-
|
|
9985
|
+
logger21.error({ streamError }, "Failed to write error to stream");
|
|
9849
9986
|
}
|
|
9850
9987
|
}
|
|
9851
9988
|
});
|
|
9852
9989
|
} catch (error) {
|
|
9853
|
-
|
|
9990
|
+
logger21.error(
|
|
9854
9991
|
{
|
|
9855
9992
|
error: error instanceof Error ? error.message : error,
|
|
9856
9993
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -9878,7 +10015,7 @@ var chat_default = app2;
|
|
|
9878
10015
|
init_dbClient();
|
|
9879
10016
|
init_logger();
|
|
9880
10017
|
var app3 = new zodOpenapi.OpenAPIHono();
|
|
9881
|
-
var
|
|
10018
|
+
var logger22 = agentsCore.getLogger("chatDataStream");
|
|
9882
10019
|
var chatDataStreamRoute = zodOpenapi.createRoute({
|
|
9883
10020
|
method: "post",
|
|
9884
10021
|
path: "/chat",
|
|
@@ -9995,7 +10132,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
9995
10132
|
});
|
|
9996
10133
|
const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
|
|
9997
10134
|
const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
|
|
9998
|
-
|
|
10135
|
+
logger22.info({ userText, lastUserMessage }, "userText");
|
|
9999
10136
|
const messageSpan = api.trace.getActiveSpan();
|
|
10000
10137
|
if (messageSpan) {
|
|
10001
10138
|
messageSpan.setAttributes({
|
|
@@ -10037,7 +10174,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
10037
10174
|
await streamHelper.writeOperation(errorOp("Unable to process request", "system"));
|
|
10038
10175
|
}
|
|
10039
10176
|
} catch (err) {
|
|
10040
|
-
|
|
10177
|
+
logger22.error({ err }, "Streaming error");
|
|
10041
10178
|
await streamHelper.writeOperation(errorOp("Internal server error", "system"));
|
|
10042
10179
|
} finally {
|
|
10043
10180
|
if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
|
|
@@ -10058,7 +10195,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
10058
10195
|
)
|
|
10059
10196
|
);
|
|
10060
10197
|
} catch (error) {
|
|
10061
|
-
|
|
10198
|
+
logger22.error({ error }, "chatDataStream error");
|
|
10062
10199
|
throw agentsCore.createApiError({
|
|
10063
10200
|
code: "internal_server_error",
|
|
10064
10201
|
message: "Failed to process chat completion"
|
|
@@ -10073,7 +10210,7 @@ init_logger();
|
|
|
10073
10210
|
function createMCPSchema(schema) {
|
|
10074
10211
|
return schema;
|
|
10075
10212
|
}
|
|
10076
|
-
var
|
|
10213
|
+
var logger23 = agentsCore.getLogger("mcp");
|
|
10077
10214
|
var _MockResponseSingleton = class _MockResponseSingleton {
|
|
10078
10215
|
constructor() {
|
|
10079
10216
|
__publicField(this, "mockRes");
|
|
@@ -10128,21 +10265,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
|
|
|
10128
10265
|
id: 0
|
|
10129
10266
|
});
|
|
10130
10267
|
var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
|
|
10131
|
-
|
|
10268
|
+
logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
|
|
10132
10269
|
const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
|
|
10133
10270
|
const mockRes = MockResponseSingleton.getInstance().getMockResponse();
|
|
10134
10271
|
try {
|
|
10135
10272
|
await transport.handleRequest(req, mockRes, spoofInitMessage);
|
|
10136
|
-
|
|
10273
|
+
logger23.info({ sessionId }, "Successfully spoofed initialization");
|
|
10137
10274
|
} catch (spoofError) {
|
|
10138
|
-
|
|
10275
|
+
logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
|
|
10139
10276
|
}
|
|
10140
10277
|
};
|
|
10141
10278
|
var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
10142
10279
|
const sessionId = req.headers["mcp-session-id"];
|
|
10143
|
-
|
|
10280
|
+
logger23.info({ sessionId }, "Received MCP session ID");
|
|
10144
10281
|
if (!sessionId) {
|
|
10145
|
-
|
|
10282
|
+
logger23.info({ body }, "Missing session ID");
|
|
10146
10283
|
res.writeHead(400).end(
|
|
10147
10284
|
JSON.stringify({
|
|
10148
10285
|
jsonrpc: "2.0",
|
|
@@ -10168,7 +10305,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
|
10168
10305
|
scopes: { tenantId, projectId },
|
|
10169
10306
|
conversationId: sessionId
|
|
10170
10307
|
});
|
|
10171
|
-
|
|
10308
|
+
logger23.info(
|
|
10172
10309
|
{
|
|
10173
10310
|
sessionId,
|
|
10174
10311
|
conversationFound: !!conversation,
|
|
@@ -10179,7 +10316,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
|
10179
10316
|
"Conversation lookup result"
|
|
10180
10317
|
);
|
|
10181
10318
|
if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
|
|
10182
|
-
|
|
10319
|
+
logger23.info(
|
|
10183
10320
|
{ sessionId, conversationId: conversation?.id },
|
|
10184
10321
|
"MCP session not found or invalid"
|
|
10185
10322
|
);
|
|
@@ -10240,7 +10377,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
|
|
|
10240
10377
|
requestId: requestId2,
|
|
10241
10378
|
sseHelper: mcpStreamHelper
|
|
10242
10379
|
});
|
|
10243
|
-
|
|
10380
|
+
logger23.info(
|
|
10244
10381
|
{ result },
|
|
10245
10382
|
`Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
|
|
10246
10383
|
);
|
|
@@ -10324,7 +10461,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
|
|
|
10324
10461
|
dbClient: dbClient_default,
|
|
10325
10462
|
credentialStores
|
|
10326
10463
|
});
|
|
10327
|
-
|
|
10464
|
+
logger23.info(
|
|
10328
10465
|
{
|
|
10329
10466
|
tenantId,
|
|
10330
10467
|
projectId,
|
|
@@ -10386,7 +10523,7 @@ var validateRequestParameters = (c) => {
|
|
|
10386
10523
|
};
|
|
10387
10524
|
var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
|
|
10388
10525
|
const { tenantId, projectId, graphId } = executionContext;
|
|
10389
|
-
|
|
10526
|
+
logger23.info({ body }, "Received initialization request");
|
|
10390
10527
|
const sessionId = nanoid.nanoid();
|
|
10391
10528
|
const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
|
|
10392
10529
|
scopes: { tenantId, projectId, graphId }
|
|
@@ -10426,7 +10563,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
10426
10563
|
}
|
|
10427
10564
|
}
|
|
10428
10565
|
});
|
|
10429
|
-
|
|
10566
|
+
logger23.info(
|
|
10430
10567
|
{ sessionId, conversationId: conversation.id },
|
|
10431
10568
|
"Created MCP session as conversation"
|
|
10432
10569
|
);
|
|
@@ -10435,9 +10572,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
10435
10572
|
});
|
|
10436
10573
|
const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
|
|
10437
10574
|
await server.connect(transport);
|
|
10438
|
-
|
|
10575
|
+
logger23.info({ sessionId }, "Server connected for initialization");
|
|
10439
10576
|
res.setHeader("Mcp-Session-Id", sessionId);
|
|
10440
|
-
|
|
10577
|
+
logger23.info(
|
|
10441
10578
|
{
|
|
10442
10579
|
sessionId,
|
|
10443
10580
|
bodyMethod: body?.method,
|
|
@@ -10446,7 +10583,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
10446
10583
|
"About to handle initialization request"
|
|
10447
10584
|
);
|
|
10448
10585
|
await transport.handleRequest(req, res, body);
|
|
10449
|
-
|
|
10586
|
+
logger23.info({ sessionId }, "Successfully handled initialization request");
|
|
10450
10587
|
return fetchToNode.toFetchResponse(res);
|
|
10451
10588
|
};
|
|
10452
10589
|
var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
|
|
@@ -10474,8 +10611,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
|
|
|
10474
10611
|
sessionId,
|
|
10475
10612
|
conversation.metadata?.session_data?.mcpProtocolVersion
|
|
10476
10613
|
);
|
|
10477
|
-
|
|
10478
|
-
|
|
10614
|
+
logger23.info({ sessionId }, "Server connected and transport initialized");
|
|
10615
|
+
logger23.info(
|
|
10479
10616
|
{
|
|
10480
10617
|
sessionId,
|
|
10481
10618
|
bodyKeys: Object.keys(body || {}),
|
|
@@ -10489,9 +10626,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
|
|
|
10489
10626
|
);
|
|
10490
10627
|
try {
|
|
10491
10628
|
await transport.handleRequest(req, res, body);
|
|
10492
|
-
|
|
10629
|
+
logger23.info({ sessionId }, "Successfully handled MCP request");
|
|
10493
10630
|
} catch (transportError) {
|
|
10494
|
-
|
|
10631
|
+
logger23.error(
|
|
10495
10632
|
{
|
|
10496
10633
|
sessionId,
|
|
10497
10634
|
error: transportError,
|
|
@@ -10542,13 +10679,13 @@ app4.openapi(
|
|
|
10542
10679
|
}
|
|
10543
10680
|
const { executionContext } = paramValidation;
|
|
10544
10681
|
const body = c.get("requestBody") || {};
|
|
10545
|
-
|
|
10682
|
+
logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
|
|
10546
10683
|
const isInitRequest = body.method === "initialize";
|
|
10547
10684
|
const { req, res } = fetchToNode.toReqRes(c.req.raw);
|
|
10548
10685
|
const validatedContext = c.get("validatedContext") || {};
|
|
10549
10686
|
const credentialStores = c.get("credentialStores");
|
|
10550
|
-
|
|
10551
|
-
|
|
10687
|
+
logger23.info({ validatedContext }, "Validated context");
|
|
10688
|
+
logger23.info({ req }, "request");
|
|
10552
10689
|
if (isInitRequest) {
|
|
10553
10690
|
return await handleInitializationRequest(
|
|
10554
10691
|
body,
|
|
@@ -10570,7 +10707,7 @@ app4.openapi(
|
|
|
10570
10707
|
);
|
|
10571
10708
|
}
|
|
10572
10709
|
} catch (e) {
|
|
10573
|
-
|
|
10710
|
+
logger23.error(
|
|
10574
10711
|
{
|
|
10575
10712
|
error: e instanceof Error ? e.message : e,
|
|
10576
10713
|
stack: e instanceof Error ? e.stack : void 0
|
|
@@ -10582,7 +10719,7 @@ app4.openapi(
|
|
|
10582
10719
|
}
|
|
10583
10720
|
);
|
|
10584
10721
|
app4.get("/", async (c) => {
|
|
10585
|
-
|
|
10722
|
+
logger23.info({}, "Received GET MCP request");
|
|
10586
10723
|
return c.json(
|
|
10587
10724
|
{
|
|
10588
10725
|
jsonrpc: "2.0",
|
|
@@ -10596,7 +10733,7 @@ app4.get("/", async (c) => {
|
|
|
10596
10733
|
);
|
|
10597
10734
|
});
|
|
10598
10735
|
app4.delete("/", async (c) => {
|
|
10599
|
-
|
|
10736
|
+
logger23.info({}, "Received DELETE MCP request");
|
|
10600
10737
|
return c.json(
|
|
10601
10738
|
{
|
|
10602
10739
|
jsonrpc: "2.0",
|
|
@@ -10609,7 +10746,7 @@ app4.delete("/", async (c) => {
|
|
|
10609
10746
|
var mcp_default = app4;
|
|
10610
10747
|
|
|
10611
10748
|
// src/app.ts
|
|
10612
|
-
var
|
|
10749
|
+
var logger24 = agentsCore.getLogger("agents-run-api");
|
|
10613
10750
|
function createExecutionHono(serverConfig, credentialStores) {
|
|
10614
10751
|
const app6 = new zodOpenapi.OpenAPIHono();
|
|
10615
10752
|
app6.use("*", otel.otel());
|
|
@@ -10625,7 +10762,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10625
10762
|
const body = await c.req.json();
|
|
10626
10763
|
c.set("requestBody", body);
|
|
10627
10764
|
} catch (error) {
|
|
10628
|
-
|
|
10765
|
+
logger24.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
|
|
10629
10766
|
}
|
|
10630
10767
|
}
|
|
10631
10768
|
return next();
|
|
@@ -10676,8 +10813,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10676
10813
|
if (!isExpectedError) {
|
|
10677
10814
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
10678
10815
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
10679
|
-
if (
|
|
10680
|
-
|
|
10816
|
+
if (logger24) {
|
|
10817
|
+
logger24.error(
|
|
10681
10818
|
{
|
|
10682
10819
|
error: err,
|
|
10683
10820
|
message: errorMessage,
|
|
@@ -10689,8 +10826,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10689
10826
|
);
|
|
10690
10827
|
}
|
|
10691
10828
|
} else {
|
|
10692
|
-
if (
|
|
10693
|
-
|
|
10829
|
+
if (logger24) {
|
|
10830
|
+
logger24.error(
|
|
10694
10831
|
{
|
|
10695
10832
|
error: err,
|
|
10696
10833
|
path: c.req.path,
|
|
@@ -10707,8 +10844,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10707
10844
|
const response = err.getResponse();
|
|
10708
10845
|
return response;
|
|
10709
10846
|
} catch (responseError) {
|
|
10710
|
-
if (
|
|
10711
|
-
|
|
10847
|
+
if (logger24) {
|
|
10848
|
+
logger24.error({ error: responseError }, "Error while handling HTTPException response");
|
|
10712
10849
|
}
|
|
10713
10850
|
}
|
|
10714
10851
|
}
|
|
@@ -10742,7 +10879,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10742
10879
|
app6.use("*", async (c, next) => {
|
|
10743
10880
|
const executionContext = c.get("executionContext");
|
|
10744
10881
|
if (!executionContext) {
|
|
10745
|
-
|
|
10882
|
+
logger24.debug({}, "Empty execution context");
|
|
10746
10883
|
return next();
|
|
10747
10884
|
}
|
|
10748
10885
|
const { tenantId, projectId, graphId } = executionContext;
|
|
@@ -10751,7 +10888,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10751
10888
|
if (requestBody) {
|
|
10752
10889
|
conversationId = requestBody.conversationId;
|
|
10753
10890
|
if (!conversationId) {
|
|
10754
|
-
|
|
10891
|
+
logger24.debug({ requestBody }, "No conversation ID found in request body");
|
|
10755
10892
|
}
|
|
10756
10893
|
}
|
|
10757
10894
|
const entries = Object.fromEntries(
|
|
@@ -10766,7 +10903,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10766
10903
|
})
|
|
10767
10904
|
);
|
|
10768
10905
|
if (!Object.keys(entries).length) {
|
|
10769
|
-
|
|
10906
|
+
logger24.debug({}, "Empty entries for baggage");
|
|
10770
10907
|
return next();
|
|
10771
10908
|
}
|
|
10772
10909
|
const bag = Object.entries(entries).reduce(
|