@inkeep/agents-run-api 0.11.3 → 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,91 +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
|
-
"artifact.type": artifactData.artifactType,
|
|
3384
|
-
"artifact.summary": JSON.stringify(artifactData.summaryProps, null, 2),
|
|
3385
|
-
"artifact.full": JSON.stringify(artifactData.fullProps, null, 2),
|
|
3386
|
-
"prompt.length": prompt.length
|
|
3387
|
-
}
|
|
3388
|
-
},
|
|
3389
|
-
async (generationSpan) => {
|
|
3390
|
-
const maxRetries = 3;
|
|
3391
|
-
let lastError = null;
|
|
3392
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
3361
|
+
if (artifactData.agentId && artifactData.tenantId && artifactData.projectId) {
|
|
3393
3362
|
try {
|
|
3394
|
-
const
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
recordInputs: true,
|
|
3402
|
-
recordOutputs: true,
|
|
3403
|
-
metadata: {
|
|
3404
|
-
operation: "artifact_name_description_generation",
|
|
3405
|
-
sessionId: this.sessionId,
|
|
3406
|
-
attempt
|
|
3407
|
-
}
|
|
3408
|
-
}
|
|
3409
|
-
});
|
|
3410
|
-
generationSpan.setAttributes({
|
|
3411
|
-
"artifact.id": artifactData.artifactId,
|
|
3412
|
-
"artifact.type": artifactData.artifactType,
|
|
3413
|
-
"artifact.name": result2.object.name,
|
|
3414
|
-
"artifact.description": result2.object.description,
|
|
3415
|
-
"artifact.summary": JSON.stringify(artifactData.summaryProps, null, 2),
|
|
3416
|
-
"artifact.full": JSON.stringify(artifactData.fullProps, null, 2),
|
|
3417
|
-
"generation.name_length": result2.object.name.length,
|
|
3418
|
-
"generation.description_length": result2.object.description.length,
|
|
3419
|
-
"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
|
|
3420
3370
|
});
|
|
3421
|
-
|
|
3422
|
-
|
|
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
|
+
}
|
|
3423
3383
|
} catch (error) {
|
|
3424
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
3425
3384
|
logger8.warn(
|
|
3426
3385
|
{
|
|
3427
3386
|
sessionId: this.sessionId,
|
|
3428
3387
|
artifactId: artifactData.artifactId,
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
error: lastError.message
|
|
3388
|
+
agentId: artifactData.agentId,
|
|
3389
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
3432
3390
|
},
|
|
3433
|
-
|
|
3391
|
+
"Failed to get agent model configuration"
|
|
3434
3392
|
);
|
|
3435
|
-
if (attempt < maxRetries) {
|
|
3436
|
-
const backoffMs = Math.min(1e3 * 2 ** (attempt - 1), 1e4);
|
|
3437
|
-
await new Promise((resolve) => setTimeout(resolve, backoffMs));
|
|
3438
|
-
}
|
|
3439
3393
|
}
|
|
3440
3394
|
}
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
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;
|
|
3445
3407
|
}
|
|
3446
|
-
|
|
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
|
+
}
|
|
3447
3494
|
const artifactService = new ArtifactService({
|
|
3448
3495
|
tenantId: artifactData.tenantId,
|
|
3449
3496
|
projectId: artifactData.projectId,
|
|
@@ -3700,8 +3747,10 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3700
3747
|
__publicField(this, "lastStreamedComponents", /* @__PURE__ */ new Map());
|
|
3701
3748
|
__publicField(this, "componentSnapshots", /* @__PURE__ */ new Map());
|
|
3702
3749
|
__publicField(this, "artifactMap");
|
|
3750
|
+
__publicField(this, "agentId");
|
|
3703
3751
|
this.streamHelper = streamHelper;
|
|
3704
3752
|
this.contextId = contextId;
|
|
3753
|
+
this.agentId = artifactParserOptions?.agentId;
|
|
3705
3754
|
if (artifactParserOptions?.streamRequestId) {
|
|
3706
3755
|
const sessionParser = graphSessionManager.getArtifactParser(
|
|
3707
3756
|
artifactParserOptions.streamRequestId
|
|
@@ -3830,7 +3879,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3830
3879
|
async streamComponent(component) {
|
|
3831
3880
|
const parts = await this.artifactParser.parseObject({
|
|
3832
3881
|
dataComponents: [component]
|
|
3833
|
-
});
|
|
3882
|
+
}, this.artifactMap, this.agentId);
|
|
3834
3883
|
if (!Array.isArray(parts)) {
|
|
3835
3884
|
console.warn("parseObject returned non-array:", parts);
|
|
3836
3885
|
return;
|
|
@@ -3902,7 +3951,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3902
3951
|
if (!hasBeenStreamed && this.isComponentComplete(component) && component.name !== "Text") {
|
|
3903
3952
|
const parts = await this.artifactParser.parseObject({
|
|
3904
3953
|
dataComponents: [component]
|
|
3905
|
-
});
|
|
3954
|
+
}, this.artifactMap, this.agentId);
|
|
3906
3955
|
for (const part of parts) {
|
|
3907
3956
|
await this.streamPart(part);
|
|
3908
3957
|
}
|
|
@@ -3955,7 +4004,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3955
4004
|
const safeEnd = this.artifactParser.findSafeTextBoundary(workingBuffer);
|
|
3956
4005
|
if (safeEnd > 0) {
|
|
3957
4006
|
const safeText = workingBuffer.slice(0, safeEnd);
|
|
3958
|
-
const parts2 = await this.artifactParser.parseText(safeText, this.artifactMap);
|
|
4007
|
+
const parts2 = await this.artifactParser.parseText(safeText, this.artifactMap, this.agentId);
|
|
3959
4008
|
completeParts.push(...parts2);
|
|
3960
4009
|
return {
|
|
3961
4010
|
completeParts,
|
|
@@ -3967,7 +4016,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
|
|
|
3967
4016
|
remainingBuffer: workingBuffer
|
|
3968
4017
|
};
|
|
3969
4018
|
}
|
|
3970
|
-
const parts = await this.artifactParser.parseText(workingBuffer, this.artifactMap);
|
|
4019
|
+
const parts = await this.artifactParser.parseText(workingBuffer, this.artifactMap, this.agentId);
|
|
3971
4020
|
if (parts.length > 0 && parts[parts.length - 1].kind === "text") {
|
|
3972
4021
|
const lastPart = parts[parts.length - 1];
|
|
3973
4022
|
const lastText = lastPart.text || "";
|
|
@@ -4044,6 +4093,8 @@ var logger10 = agentsCore.getLogger("ResponseFormatter");
|
|
|
4044
4093
|
var ResponseFormatter = class {
|
|
4045
4094
|
constructor(tenantId, artifactParserOptions) {
|
|
4046
4095
|
__publicField(this, "artifactParser");
|
|
4096
|
+
__publicField(this, "agentId");
|
|
4097
|
+
this.agentId = artifactParserOptions?.agentId;
|
|
4047
4098
|
if (artifactParserOptions?.streamRequestId) {
|
|
4048
4099
|
const sessionParser = graphSessionManager.getArtifactParser(artifactParserOptions.streamRequestId);
|
|
4049
4100
|
if (sessionParser) {
|
|
@@ -4064,7 +4115,7 @@ var ResponseFormatter = class {
|
|
|
4064
4115
|
"response.type": "object",
|
|
4065
4116
|
"response.availableArtifacts": artifactMap.size
|
|
4066
4117
|
});
|
|
4067
|
-
const parts = await this.artifactParser.parseObject(responseObject, artifactMap);
|
|
4118
|
+
const parts = await this.artifactParser.parseObject(responseObject, artifactMap, this.agentId);
|
|
4068
4119
|
const uniqueArtifacts = this.countUniqueArtifacts(parts);
|
|
4069
4120
|
span.setAttributes({
|
|
4070
4121
|
"response.dataPartsCount": parts.length,
|
|
@@ -4093,8 +4144,9 @@ var ResponseFormatter = class {
|
|
|
4093
4144
|
async formatResponse(responseText, contextId) {
|
|
4094
4145
|
return tracer.startActiveSpan("response.format_response", async (span) => {
|
|
4095
4146
|
try {
|
|
4147
|
+
const hasMarkers = this.artifactParser.hasArtifactMarkers(responseText);
|
|
4096
4148
|
span.setAttributes({
|
|
4097
|
-
"response.hasArtifactMarkers":
|
|
4149
|
+
"response.hasArtifactMarkers": hasMarkers,
|
|
4098
4150
|
"response.contextId": contextId,
|
|
4099
4151
|
"response.textLength": responseText.length
|
|
4100
4152
|
});
|
|
@@ -4109,7 +4161,7 @@ var ResponseFormatter = class {
|
|
|
4109
4161
|
"response.type": "text",
|
|
4110
4162
|
"response.availableArtifacts": artifactMap.size
|
|
4111
4163
|
});
|
|
4112
|
-
const parts = await this.artifactParser.parseText(responseText, artifactMap);
|
|
4164
|
+
const parts = await this.artifactParser.parseText(responseText, artifactMap, this.agentId);
|
|
4113
4165
|
if (parts.length === 1 && parts[0].kind === "text") {
|
|
4114
4166
|
return { text: parts[0].text };
|
|
4115
4167
|
}
|
|
@@ -5576,6 +5628,14 @@ CITATION PLACEMENT RULES:
|
|
|
5576
5628
|
|
|
5577
5629
|
\u{1F3AF} **KEY PRINCIPLE**: Information from tools \u2192 Complete thought \u2192 Punctuation \u2192 Citation \u2192 Continue
|
|
5578
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
|
+
|
|
5579
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.`;
|
|
5580
5640
|
|
|
5581
5641
|
// templates/v1/phase1/system-prompt.xml?raw
|
|
@@ -5614,6 +5674,20 @@ var system_prompt_default = `<system_message>
|
|
|
5614
5674
|
- Save important tool results as artifacts when they contain structured data that should be preserved and referenced
|
|
5615
5675
|
- Ask for clarification when requests are ambiguous
|
|
5616
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
|
+
|
|
5617
5691
|
\u{1F6A8} TRANSFER TOOL RULES - CRITICAL:
|
|
5618
5692
|
- When calling transfer_to_* tools, call the tool IMMEDIATELY without any explanatory text
|
|
5619
5693
|
- Do NOT explain the transfer, do NOT say "I'll hand this off", do NOT provide reasoning
|
|
@@ -5681,6 +5755,8 @@ var thinking_preparation_default = `<thinking_preparation_mode>
|
|
|
5681
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> ";
|
|
5682
5756
|
|
|
5683
5757
|
// src/agents/versions/v1/Phase1Config.ts
|
|
5758
|
+
init_logger();
|
|
5759
|
+
agentsCore.getLogger("Phase1Config");
|
|
5684
5760
|
var Phase1Config = class _Phase1Config {
|
|
5685
5761
|
loadTemplates() {
|
|
5686
5762
|
const templates = /* @__PURE__ */ new Map();
|
|
@@ -5773,13 +5849,18 @@ var Phase1Config = class _Phase1Config {
|
|
|
5773
5849
|
if (!hasTransferRelations) {
|
|
5774
5850
|
return "";
|
|
5775
5851
|
}
|
|
5776
|
-
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`;
|
|
5777
5855
|
}
|
|
5778
5856
|
generateDelegationInstructions(hasDelegateRelations) {
|
|
5779
5857
|
if (!hasDelegateRelations) {
|
|
5780
5858
|
return "";
|
|
5781
5859
|
}
|
|
5782
|
-
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`;
|
|
5783
5864
|
}
|
|
5784
5865
|
getArtifactCreationGuidance() {
|
|
5785
5866
|
return `\u{1F6A8} MANDATORY ARTIFACT CREATION \u{1F6A8}
|
|
@@ -5956,10 +6037,16 @@ The implementation details show that you need to register your application first
|
|
|
5956
6037
|
|
|
5957
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."
|
|
5958
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
|
+
|
|
5959
6047
|
IMPORTANT GUIDELINES:
|
|
5960
|
-
- You can only reference artifacts that already exist
|
|
5961
|
-
- Use artifact:ref annotations in your text
|
|
5962
|
-
- 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
|
|
5963
6050
|
- References are automatically converted to interactive elements`;
|
|
5964
6051
|
}
|
|
5965
6052
|
return "";
|
|
@@ -6100,7 +6187,43 @@ ${propertiesXml}
|
|
|
6100
6187
|
};
|
|
6101
6188
|
|
|
6102
6189
|
// templates/v1/phase2/system-prompt.xml?raw
|
|
6103
|
-
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>`;
|
|
6104
6227
|
|
|
6105
6228
|
// templates/v1/phase2/data-components.xml?raw
|
|
6106
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>';
|
|
@@ -6209,8 +6332,11 @@ COMMON FAILURE POINTS (AVOID THESE):
|
|
|
6209
6332
|
if (!shouldShowReferencingRules) {
|
|
6210
6333
|
return "";
|
|
6211
6334
|
}
|
|
6335
|
+
const sharedGuidance = artifact_retrieval_guidance_default;
|
|
6212
6336
|
if (hasArtifactComponents && artifactComponents && artifactComponents.length > 0) {
|
|
6213
|
-
return
|
|
6337
|
+
return `${sharedGuidance}
|
|
6338
|
+
|
|
6339
|
+
ARTIFACT MANAGEMENT FOR STRUCTURED RESPONSES:
|
|
6214
6340
|
|
|
6215
6341
|
You will create and reference artifacts using data components in your JSON response.
|
|
6216
6342
|
|
|
@@ -6290,12 +6416,14 @@ COMPONENT GUIDELINES:
|
|
|
6290
6416
|
- Only add Artifact reference components when citing the SAME artifact again for a different point
|
|
6291
6417
|
- Use tool_call_id exactly as it appears in tool execution results`;
|
|
6292
6418
|
}
|
|
6293
|
-
return
|
|
6419
|
+
return `${sharedGuidance}
|
|
6420
|
+
|
|
6421
|
+
ARTIFACT REFERENCING FOR STRUCTURED RESPONSES:
|
|
6294
6422
|
|
|
6295
6423
|
You can reference existing artifacts but cannot create new ones.
|
|
6296
6424
|
|
|
6297
6425
|
HOW TO REFERENCE ARTIFACTS:
|
|
6298
|
-
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.
|
|
6299
6427
|
|
|
6300
6428
|
EXAMPLE STRUCTURED RESPONSE:
|
|
6301
6429
|
\`\`\`json
|
|
@@ -6469,7 +6597,7 @@ function hasToolCallWithPrefix(prefix) {
|
|
|
6469
6597
|
return false;
|
|
6470
6598
|
};
|
|
6471
6599
|
}
|
|
6472
|
-
var
|
|
6600
|
+
var logger16 = agentsCore.getLogger("Agent");
|
|
6473
6601
|
var CONSTANTS = {
|
|
6474
6602
|
MAX_GENERATION_STEPS: 12,
|
|
6475
6603
|
PHASE_1_TIMEOUT_MS: 27e4,
|
|
@@ -6768,14 +6896,14 @@ var Agent = class {
|
|
|
6768
6896
|
for (const toolSet of tools) {
|
|
6769
6897
|
for (const [toolName, originalTool] of Object.entries(toolSet)) {
|
|
6770
6898
|
if (!isValidTool(originalTool)) {
|
|
6771
|
-
|
|
6899
|
+
logger16.error({ toolName }, "Invalid MCP tool structure - missing required properties");
|
|
6772
6900
|
continue;
|
|
6773
6901
|
}
|
|
6774
6902
|
const sessionWrappedTool = ai.tool({
|
|
6775
6903
|
description: originalTool.description,
|
|
6776
6904
|
inputSchema: originalTool.inputSchema,
|
|
6777
6905
|
execute: async (args, { toolCallId }) => {
|
|
6778
|
-
|
|
6906
|
+
logger16.debug({ toolName, toolCallId }, "MCP Tool Called");
|
|
6779
6907
|
try {
|
|
6780
6908
|
const rawResult = await originalTool.execute(args, { toolCallId });
|
|
6781
6909
|
const parsedResult = parseEmbeddedJson(rawResult);
|
|
@@ -6789,7 +6917,7 @@ var Agent = class {
|
|
|
6789
6917
|
});
|
|
6790
6918
|
return { result: enhancedResult, toolCallId };
|
|
6791
6919
|
} catch (error) {
|
|
6792
|
-
|
|
6920
|
+
logger16.error({ toolName, toolCallId, error }, "MCP tool execution failed");
|
|
6793
6921
|
throw error;
|
|
6794
6922
|
}
|
|
6795
6923
|
}
|
|
@@ -6883,7 +7011,7 @@ var Agent = class {
|
|
|
6883
7011
|
headers: agentToolRelationHeaders
|
|
6884
7012
|
};
|
|
6885
7013
|
}
|
|
6886
|
-
|
|
7014
|
+
logger16.info(
|
|
6887
7015
|
{
|
|
6888
7016
|
toolName: tool3.name,
|
|
6889
7017
|
credentialReferenceId,
|
|
@@ -6923,7 +7051,7 @@ var Agent = class {
|
|
|
6923
7051
|
async getResolvedContext(conversationId, requestContext) {
|
|
6924
7052
|
try {
|
|
6925
7053
|
if (!this.config.contextConfigId) {
|
|
6926
|
-
|
|
7054
|
+
logger16.debug({ graphId: this.config.graphId }, "No context config found for graph");
|
|
6927
7055
|
return null;
|
|
6928
7056
|
}
|
|
6929
7057
|
const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
|
|
@@ -6931,7 +7059,7 @@ var Agent = class {
|
|
|
6931
7059
|
id: this.config.contextConfigId
|
|
6932
7060
|
});
|
|
6933
7061
|
if (!contextConfig) {
|
|
6934
|
-
|
|
7062
|
+
logger16.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
|
|
6935
7063
|
return null;
|
|
6936
7064
|
}
|
|
6937
7065
|
if (!this.contextResolver) {
|
|
@@ -6948,7 +7076,7 @@ var Agent = class {
|
|
|
6948
7076
|
$now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6949
7077
|
$env: process.env
|
|
6950
7078
|
};
|
|
6951
|
-
|
|
7079
|
+
logger16.debug(
|
|
6952
7080
|
{
|
|
6953
7081
|
conversationId,
|
|
6954
7082
|
contextConfigId: contextConfig.id,
|
|
@@ -6962,7 +7090,7 @@ var Agent = class {
|
|
|
6962
7090
|
);
|
|
6963
7091
|
return contextWithBuiltins;
|
|
6964
7092
|
} catch (error) {
|
|
6965
|
-
|
|
7093
|
+
logger16.error(
|
|
6966
7094
|
{
|
|
6967
7095
|
conversationId,
|
|
6968
7096
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -6986,7 +7114,7 @@ var Agent = class {
|
|
|
6986
7114
|
});
|
|
6987
7115
|
return graphDefinition?.graphPrompt || void 0;
|
|
6988
7116
|
} catch (error) {
|
|
6989
|
-
|
|
7117
|
+
logger16.warn(
|
|
6990
7118
|
{
|
|
6991
7119
|
graphId: this.config.graphId,
|
|
6992
7120
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -7015,7 +7143,7 @@ var Agent = class {
|
|
|
7015
7143
|
(agent) => "artifactComponents" in agent && agent.artifactComponents && agent.artifactComponents.length > 0
|
|
7016
7144
|
);
|
|
7017
7145
|
} catch (error) {
|
|
7018
|
-
|
|
7146
|
+
logger16.warn(
|
|
7019
7147
|
{
|
|
7020
7148
|
graphId: this.config.graphId,
|
|
7021
7149
|
tenantId: this.config.tenantId,
|
|
@@ -7044,7 +7172,7 @@ var Agent = class {
|
|
|
7044
7172
|
preserveUnresolved: false
|
|
7045
7173
|
});
|
|
7046
7174
|
} catch (error) {
|
|
7047
|
-
|
|
7175
|
+
logger16.error(
|
|
7048
7176
|
{
|
|
7049
7177
|
conversationId,
|
|
7050
7178
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -7091,7 +7219,7 @@ var Agent = class {
|
|
|
7091
7219
|
preserveUnresolved: false
|
|
7092
7220
|
});
|
|
7093
7221
|
} catch (error) {
|
|
7094
|
-
|
|
7222
|
+
logger16.error(
|
|
7095
7223
|
{
|
|
7096
7224
|
conversationId,
|
|
7097
7225
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -7130,7 +7258,7 @@ var Agent = class {
|
|
|
7130
7258
|
preserveUnresolved: false
|
|
7131
7259
|
});
|
|
7132
7260
|
} catch (error) {
|
|
7133
|
-
|
|
7261
|
+
logger16.error(
|
|
7134
7262
|
{
|
|
7135
7263
|
conversationId,
|
|
7136
7264
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -7162,7 +7290,7 @@ var Agent = class {
|
|
|
7162
7290
|
artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
|
|
7163
7291
|
}),
|
|
7164
7292
|
execute: async ({ artifactId }) => {
|
|
7165
|
-
|
|
7293
|
+
logger16.info({ artifactId }, "get_artifact executed");
|
|
7166
7294
|
const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
|
|
7167
7295
|
scopes: {
|
|
7168
7296
|
tenantId: this.config.tenantId,
|
|
@@ -7412,7 +7540,7 @@ var Agent = class {
|
|
|
7412
7540
|
};
|
|
7413
7541
|
return enhanced;
|
|
7414
7542
|
} catch (error) {
|
|
7415
|
-
|
|
7543
|
+
logger16.warn({ error }, "Failed to enhance tool result with structure hints");
|
|
7416
7544
|
return result;
|
|
7417
7545
|
}
|
|
7418
7546
|
}
|
|
@@ -7427,7 +7555,7 @@ var Agent = class {
|
|
|
7427
7555
|
}
|
|
7428
7556
|
});
|
|
7429
7557
|
} catch (error) {
|
|
7430
|
-
|
|
7558
|
+
logger16.error(
|
|
7431
7559
|
{ error, graphId: this.config.graphId },
|
|
7432
7560
|
"Failed to check graph artifact components"
|
|
7433
7561
|
);
|
|
@@ -7527,7 +7655,7 @@ var Agent = class {
|
|
|
7527
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;
|
|
7528
7656
|
const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
|
|
7529
7657
|
if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
|
|
7530
|
-
|
|
7658
|
+
logger16.warn(
|
|
7531
7659
|
{
|
|
7532
7660
|
requestedTimeout: modelSettings.maxDuration * 1e3,
|
|
7533
7661
|
appliedTimeout: timeoutMs,
|
|
@@ -7569,7 +7697,7 @@ var Agent = class {
|
|
|
7569
7697
|
}
|
|
7570
7698
|
);
|
|
7571
7699
|
} catch (error) {
|
|
7572
|
-
|
|
7700
|
+
logger16.debug({ error }, "Failed to track agent reasoning");
|
|
7573
7701
|
}
|
|
7574
7702
|
}
|
|
7575
7703
|
if (last && "toolCalls" in last && last.toolCalls) {
|
|
@@ -7666,7 +7794,7 @@ var Agent = class {
|
|
|
7666
7794
|
}
|
|
7667
7795
|
);
|
|
7668
7796
|
} catch (error) {
|
|
7669
|
-
|
|
7797
|
+
logger16.debug({ error }, "Failed to track agent reasoning");
|
|
7670
7798
|
}
|
|
7671
7799
|
}
|
|
7672
7800
|
if (last && "toolCalls" in last && last.toolCalls) {
|
|
@@ -7957,7 +8085,7 @@ ${output}${structureHintsFormatted}`;
|
|
|
7957
8085
|
};
|
|
7958
8086
|
|
|
7959
8087
|
// src/agents/generateTaskHandler.ts
|
|
7960
|
-
var
|
|
8088
|
+
var logger17 = agentsCore.getLogger("generateTaskHandler");
|
|
7961
8089
|
var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
7962
8090
|
return async (task) => {
|
|
7963
8091
|
try {
|
|
@@ -8010,7 +8138,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8010
8138
|
}
|
|
8011
8139
|
})
|
|
8012
8140
|
]);
|
|
8013
|
-
|
|
8141
|
+
logger17.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
|
|
8014
8142
|
const enhancedInternalRelations = await Promise.all(
|
|
8015
8143
|
internalRelations.map(async (relation) => {
|
|
8016
8144
|
try {
|
|
@@ -8039,7 +8167,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8039
8167
|
return { ...relation, description: enhancedDescription };
|
|
8040
8168
|
}
|
|
8041
8169
|
} catch (error) {
|
|
8042
|
-
|
|
8170
|
+
logger17.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
|
|
8043
8171
|
}
|
|
8044
8172
|
return relation;
|
|
8045
8173
|
})
|
|
@@ -8139,7 +8267,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8139
8267
|
const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
|
|
8140
8268
|
if (taskIdMatch) {
|
|
8141
8269
|
contextId = taskIdMatch[1];
|
|
8142
|
-
|
|
8270
|
+
logger17.info(
|
|
8143
8271
|
{
|
|
8144
8272
|
taskId: task.id,
|
|
8145
8273
|
extractedContextId: contextId,
|
|
@@ -8155,7 +8283,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8155
8283
|
const isDelegation = task.context?.metadata?.isDelegation === true;
|
|
8156
8284
|
agent.setDelegationStatus(isDelegation);
|
|
8157
8285
|
if (isDelegation) {
|
|
8158
|
-
|
|
8286
|
+
logger17.info(
|
|
8159
8287
|
{ agentId: config.agentId, taskId: task.id },
|
|
8160
8288
|
"Delegated agent - streaming disabled"
|
|
8161
8289
|
);
|
|
@@ -8380,7 +8508,7 @@ async function getRegisteredGraph(executionContext) {
|
|
|
8380
8508
|
init_dbClient();
|
|
8381
8509
|
init_logger();
|
|
8382
8510
|
var app = new zodOpenapi.OpenAPIHono();
|
|
8383
|
-
var
|
|
8511
|
+
var logger18 = agentsCore.getLogger("agents");
|
|
8384
8512
|
app.openapi(
|
|
8385
8513
|
zodOpenapi.createRoute({
|
|
8386
8514
|
method: "get",
|
|
@@ -8418,7 +8546,7 @@ app.openapi(
|
|
|
8418
8546
|
tracestate: c.req.header("tracestate"),
|
|
8419
8547
|
baggage: c.req.header("baggage")
|
|
8420
8548
|
};
|
|
8421
|
-
|
|
8549
|
+
logger18.info(
|
|
8422
8550
|
{
|
|
8423
8551
|
otelHeaders,
|
|
8424
8552
|
path: c.req.path,
|
|
@@ -8430,7 +8558,7 @@ app.openapi(
|
|
|
8430
8558
|
const { tenantId, projectId, graphId, agentId } = executionContext;
|
|
8431
8559
|
console.dir("executionContext", executionContext);
|
|
8432
8560
|
if (agentId) {
|
|
8433
|
-
|
|
8561
|
+
logger18.info(
|
|
8434
8562
|
{
|
|
8435
8563
|
message: "getRegisteredAgent (agent-level)",
|
|
8436
8564
|
tenantId,
|
|
@@ -8442,7 +8570,7 @@ app.openapi(
|
|
|
8442
8570
|
);
|
|
8443
8571
|
const credentialStores = c.get("credentialStores");
|
|
8444
8572
|
const agent = await getRegisteredAgent(executionContext, credentialStores);
|
|
8445
|
-
|
|
8573
|
+
logger18.info({ agent }, "agent registered: well-known agent.json");
|
|
8446
8574
|
if (!agent) {
|
|
8447
8575
|
throw agentsCore.createApiError({
|
|
8448
8576
|
code: "not_found",
|
|
@@ -8451,7 +8579,7 @@ app.openapi(
|
|
|
8451
8579
|
}
|
|
8452
8580
|
return c.json(agent.agentCard);
|
|
8453
8581
|
} else {
|
|
8454
|
-
|
|
8582
|
+
logger18.info(
|
|
8455
8583
|
{
|
|
8456
8584
|
message: "getRegisteredGraph (graph-level)",
|
|
8457
8585
|
tenantId,
|
|
@@ -8477,7 +8605,7 @@ app.post("/a2a", async (c) => {
|
|
|
8477
8605
|
tracestate: c.req.header("tracestate"),
|
|
8478
8606
|
baggage: c.req.header("baggage")
|
|
8479
8607
|
};
|
|
8480
|
-
|
|
8608
|
+
logger18.info(
|
|
8481
8609
|
{
|
|
8482
8610
|
otelHeaders,
|
|
8483
8611
|
path: c.req.path,
|
|
@@ -8488,7 +8616,7 @@ app.post("/a2a", async (c) => {
|
|
|
8488
8616
|
const executionContext = agentsCore.getRequestExecutionContext(c);
|
|
8489
8617
|
const { tenantId, projectId, graphId, agentId } = executionContext;
|
|
8490
8618
|
if (agentId) {
|
|
8491
|
-
|
|
8619
|
+
logger18.info(
|
|
8492
8620
|
{
|
|
8493
8621
|
message: "a2a (agent-level)",
|
|
8494
8622
|
tenantId,
|
|
@@ -8512,7 +8640,7 @@ app.post("/a2a", async (c) => {
|
|
|
8512
8640
|
}
|
|
8513
8641
|
return a2aHandler(c, agent);
|
|
8514
8642
|
} else {
|
|
8515
|
-
|
|
8643
|
+
logger18.info(
|
|
8516
8644
|
{
|
|
8517
8645
|
message: "a2a (graph-level)",
|
|
8518
8646
|
tenantId,
|
|
@@ -8568,14 +8696,14 @@ init_dbClient();
|
|
|
8568
8696
|
// src/a2a/transfer.ts
|
|
8569
8697
|
init_dbClient();
|
|
8570
8698
|
init_logger();
|
|
8571
|
-
var
|
|
8699
|
+
var logger19 = agentsCore.getLogger("Transfer");
|
|
8572
8700
|
async function executeTransfer({
|
|
8573
8701
|
tenantId,
|
|
8574
8702
|
threadId,
|
|
8575
8703
|
projectId,
|
|
8576
8704
|
targetAgentId
|
|
8577
8705
|
}) {
|
|
8578
|
-
|
|
8706
|
+
logger19.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
|
|
8579
8707
|
await agentsCore.setActiveAgentForThread(dbClient_default)({
|
|
8580
8708
|
scopes: { tenantId, projectId },
|
|
8581
8709
|
threadId,
|
|
@@ -9161,7 +9289,7 @@ function createMCPStreamHelper() {
|
|
|
9161
9289
|
}
|
|
9162
9290
|
|
|
9163
9291
|
// src/handlers/executionHandler.ts
|
|
9164
|
-
var
|
|
9292
|
+
var logger20 = agentsCore.getLogger("ExecutionHandler");
|
|
9165
9293
|
var ExecutionHandler = class {
|
|
9166
9294
|
constructor() {
|
|
9167
9295
|
// Hardcoded error limit - separate from configurable stopWhen
|
|
@@ -9186,7 +9314,7 @@ var ExecutionHandler = class {
|
|
|
9186
9314
|
const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
|
|
9187
9315
|
registerStreamHelper(requestId2, sseHelper);
|
|
9188
9316
|
graphSessionManager.createSession(requestId2, graphId, tenantId, projectId, conversationId);
|
|
9189
|
-
|
|
9317
|
+
logger20.info(
|
|
9190
9318
|
{ sessionId: requestId2, graphId, conversationId },
|
|
9191
9319
|
"Created GraphSession for message execution"
|
|
9192
9320
|
);
|
|
@@ -9201,7 +9329,7 @@ var ExecutionHandler = class {
|
|
|
9201
9329
|
);
|
|
9202
9330
|
}
|
|
9203
9331
|
} catch (error) {
|
|
9204
|
-
|
|
9332
|
+
logger20.error(
|
|
9205
9333
|
{
|
|
9206
9334
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
9207
9335
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -9217,7 +9345,7 @@ var ExecutionHandler = class {
|
|
|
9217
9345
|
try {
|
|
9218
9346
|
await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
|
|
9219
9347
|
const taskId = `task_${conversationId}-${requestId2}`;
|
|
9220
|
-
|
|
9348
|
+
logger20.info(
|
|
9221
9349
|
{ taskId, currentAgentId, conversationId, requestId: requestId2 },
|
|
9222
9350
|
"Attempting to create or reuse existing task"
|
|
9223
9351
|
);
|
|
@@ -9241,7 +9369,7 @@ var ExecutionHandler = class {
|
|
|
9241
9369
|
agent_id: currentAgentId
|
|
9242
9370
|
}
|
|
9243
9371
|
});
|
|
9244
|
-
|
|
9372
|
+
logger20.info(
|
|
9245
9373
|
{
|
|
9246
9374
|
taskId,
|
|
9247
9375
|
createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
|
|
@@ -9250,27 +9378,27 @@ var ExecutionHandler = class {
|
|
|
9250
9378
|
);
|
|
9251
9379
|
} catch (error) {
|
|
9252
9380
|
if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
|
|
9253
|
-
|
|
9381
|
+
logger20.info(
|
|
9254
9382
|
{ taskId, error: error.message },
|
|
9255
9383
|
"Task already exists, fetching existing task"
|
|
9256
9384
|
);
|
|
9257
9385
|
const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
|
|
9258
9386
|
if (existingTask) {
|
|
9259
9387
|
task = existingTask;
|
|
9260
|
-
|
|
9388
|
+
logger20.info(
|
|
9261
9389
|
{ taskId, existingTask },
|
|
9262
9390
|
"Successfully reused existing task from race condition"
|
|
9263
9391
|
);
|
|
9264
9392
|
} else {
|
|
9265
|
-
|
|
9393
|
+
logger20.error({ taskId, error }, "Task constraint failed but task not found");
|
|
9266
9394
|
throw error;
|
|
9267
9395
|
}
|
|
9268
9396
|
} else {
|
|
9269
|
-
|
|
9397
|
+
logger20.error({ taskId, error }, "Failed to create task due to non-constraint error");
|
|
9270
9398
|
throw error;
|
|
9271
9399
|
}
|
|
9272
9400
|
}
|
|
9273
|
-
|
|
9401
|
+
logger20.debug(
|
|
9274
9402
|
{
|
|
9275
9403
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9276
9404
|
executionType: "create_initial_task",
|
|
@@ -9288,7 +9416,7 @@ var ExecutionHandler = class {
|
|
|
9288
9416
|
const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
|
|
9289
9417
|
while (iterations < maxTransfers) {
|
|
9290
9418
|
iterations++;
|
|
9291
|
-
|
|
9419
|
+
logger20.info(
|
|
9292
9420
|
{ iterations, currentAgentId, graphId, conversationId, fromAgentId },
|
|
9293
9421
|
`Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
|
|
9294
9422
|
);
|
|
@@ -9296,10 +9424,10 @@ var ExecutionHandler = class {
|
|
|
9296
9424
|
scopes: { tenantId, projectId },
|
|
9297
9425
|
conversationId
|
|
9298
9426
|
});
|
|
9299
|
-
|
|
9427
|
+
logger20.info({ activeAgent }, "activeAgent");
|
|
9300
9428
|
if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
|
|
9301
9429
|
currentAgentId = activeAgent.activeAgentId;
|
|
9302
|
-
|
|
9430
|
+
logger20.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
|
|
9303
9431
|
}
|
|
9304
9432
|
const agentBaseUrl = `${baseUrl}/agents`;
|
|
9305
9433
|
const a2aClient = new A2AClient(agentBaseUrl, {
|
|
@@ -9340,13 +9468,13 @@ var ExecutionHandler = class {
|
|
|
9340
9468
|
});
|
|
9341
9469
|
if (!messageResponse?.result) {
|
|
9342
9470
|
errorCount++;
|
|
9343
|
-
|
|
9471
|
+
logger20.error(
|
|
9344
9472
|
{ currentAgentId, iterations, errorCount },
|
|
9345
9473
|
`No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
|
|
9346
9474
|
);
|
|
9347
9475
|
if (errorCount >= this.MAX_ERRORS) {
|
|
9348
9476
|
const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
|
|
9349
|
-
|
|
9477
|
+
logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
|
|
9350
9478
|
await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
|
|
9351
9479
|
if (task) {
|
|
9352
9480
|
await agentsCore.updateTask(dbClient_default)({
|
|
@@ -9371,7 +9499,7 @@ var ExecutionHandler = class {
|
|
|
9371
9499
|
const transferResponse = messageResponse.result;
|
|
9372
9500
|
const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
|
|
9373
9501
|
const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
|
|
9374
|
-
|
|
9502
|
+
logger20.info({ targetAgentId, transferReason }, "transfer response");
|
|
9375
9503
|
currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
|
|
9376
9504
|
const { success, targetAgentId: newAgentId } = await executeTransfer({
|
|
9377
9505
|
projectId,
|
|
@@ -9382,7 +9510,7 @@ var ExecutionHandler = class {
|
|
|
9382
9510
|
if (success) {
|
|
9383
9511
|
fromAgentId = currentAgentId;
|
|
9384
9512
|
currentAgentId = newAgentId;
|
|
9385
|
-
|
|
9513
|
+
logger20.info(
|
|
9386
9514
|
{
|
|
9387
9515
|
transferFrom: fromAgentId,
|
|
9388
9516
|
transferTo: currentAgentId,
|
|
@@ -9400,7 +9528,7 @@ var ExecutionHandler = class {
|
|
|
9400
9528
|
const graphSessionData = graphSessionManager.getSession(requestId2);
|
|
9401
9529
|
if (graphSessionData) {
|
|
9402
9530
|
const sessionSummary = graphSessionData.getSummary();
|
|
9403
|
-
|
|
9531
|
+
logger20.info(sessionSummary, "GraphSession data after completion");
|
|
9404
9532
|
}
|
|
9405
9533
|
let textContent = "";
|
|
9406
9534
|
for (const part of responseParts) {
|
|
@@ -9454,22 +9582,22 @@ var ExecutionHandler = class {
|
|
|
9454
9582
|
}
|
|
9455
9583
|
});
|
|
9456
9584
|
const updateTaskEnd = Date.now();
|
|
9457
|
-
|
|
9585
|
+
logger20.info(
|
|
9458
9586
|
{ duration: updateTaskEnd - updateTaskStart },
|
|
9459
9587
|
"Completed updateTask operation"
|
|
9460
9588
|
);
|
|
9461
9589
|
await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
|
|
9462
9590
|
await sseHelper.complete();
|
|
9463
|
-
|
|
9591
|
+
logger20.info({}, "Ending GraphSession and cleaning up");
|
|
9464
9592
|
graphSessionManager.endSession(requestId2);
|
|
9465
|
-
|
|
9593
|
+
logger20.info({}, "Cleaning up streamHelper");
|
|
9466
9594
|
unregisterStreamHelper(requestId2);
|
|
9467
9595
|
let response;
|
|
9468
9596
|
if (sseHelper instanceof MCPStreamHelper) {
|
|
9469
9597
|
const captured = sseHelper.getCapturedResponse();
|
|
9470
9598
|
response = captured.text || "No response content";
|
|
9471
9599
|
}
|
|
9472
|
-
|
|
9600
|
+
logger20.info({}, "ExecutionHandler returning success");
|
|
9473
9601
|
return { success: true, iterations, response };
|
|
9474
9602
|
} catch (error) {
|
|
9475
9603
|
agentsCore.setSpanWithError(span, error);
|
|
@@ -9480,13 +9608,13 @@ var ExecutionHandler = class {
|
|
|
9480
9608
|
});
|
|
9481
9609
|
}
|
|
9482
9610
|
errorCount++;
|
|
9483
|
-
|
|
9611
|
+
logger20.warn(
|
|
9484
9612
|
{ iterations, errorCount },
|
|
9485
9613
|
`No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
|
|
9486
9614
|
);
|
|
9487
9615
|
if (errorCount >= this.MAX_ERRORS) {
|
|
9488
9616
|
const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
|
|
9489
|
-
|
|
9617
|
+
logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
|
|
9490
9618
|
await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
|
|
9491
9619
|
if (task) {
|
|
9492
9620
|
await agentsCore.updateTask(dbClient_default)({
|
|
@@ -9507,7 +9635,7 @@ var ExecutionHandler = class {
|
|
|
9507
9635
|
}
|
|
9508
9636
|
}
|
|
9509
9637
|
const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
|
|
9510
|
-
|
|
9638
|
+
logger20.error({ maxTransfers, iterations }, errorMessage);
|
|
9511
9639
|
await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
|
|
9512
9640
|
if (task) {
|
|
9513
9641
|
await agentsCore.updateTask(dbClient_default)({
|
|
@@ -9526,7 +9654,7 @@ var ExecutionHandler = class {
|
|
|
9526
9654
|
unregisterStreamHelper(requestId2);
|
|
9527
9655
|
return { success: false, error: errorMessage, iterations };
|
|
9528
9656
|
} catch (error) {
|
|
9529
|
-
|
|
9657
|
+
logger20.error({ error }, "Error in execution handler");
|
|
9530
9658
|
const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
|
|
9531
9659
|
await sseHelper.writeOperation(
|
|
9532
9660
|
errorOp(`Execution error: ${errorMessage}`, currentAgentId || "system")
|
|
@@ -9554,7 +9682,7 @@ var ExecutionHandler = class {
|
|
|
9554
9682
|
// src/routes/chat.ts
|
|
9555
9683
|
init_logger();
|
|
9556
9684
|
var app2 = new zodOpenapi.OpenAPIHono();
|
|
9557
|
-
var
|
|
9685
|
+
var logger21 = agentsCore.getLogger("completionsHandler");
|
|
9558
9686
|
var chatCompletionsRoute = zodOpenapi.createRoute({
|
|
9559
9687
|
method: "post",
|
|
9560
9688
|
path: "/completions",
|
|
@@ -9672,7 +9800,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9672
9800
|
tracestate: c.req.header("tracestate"),
|
|
9673
9801
|
baggage: c.req.header("baggage")
|
|
9674
9802
|
};
|
|
9675
|
-
|
|
9803
|
+
logger21.info(
|
|
9676
9804
|
{
|
|
9677
9805
|
otelHeaders,
|
|
9678
9806
|
path: c.req.path,
|
|
@@ -9765,7 +9893,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9765
9893
|
dbClient: dbClient_default,
|
|
9766
9894
|
credentialStores
|
|
9767
9895
|
});
|
|
9768
|
-
|
|
9896
|
+
logger21.info(
|
|
9769
9897
|
{
|
|
9770
9898
|
tenantId,
|
|
9771
9899
|
projectId,
|
|
@@ -9813,7 +9941,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9813
9941
|
try {
|
|
9814
9942
|
const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
|
|
9815
9943
|
await sseHelper.writeRole();
|
|
9816
|
-
|
|
9944
|
+
logger21.info({ agentId }, "Starting execution");
|
|
9817
9945
|
const executionHandler = new ExecutionHandler();
|
|
9818
9946
|
const result = await executionHandler.execute({
|
|
9819
9947
|
executionContext,
|
|
@@ -9823,7 +9951,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9823
9951
|
requestId: requestId2,
|
|
9824
9952
|
sseHelper
|
|
9825
9953
|
});
|
|
9826
|
-
|
|
9954
|
+
logger21.info(
|
|
9827
9955
|
{ result },
|
|
9828
9956
|
`Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
|
|
9829
9957
|
);
|
|
@@ -9837,7 +9965,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9837
9965
|
}
|
|
9838
9966
|
await sseHelper.complete();
|
|
9839
9967
|
} catch (error) {
|
|
9840
|
-
|
|
9968
|
+
logger21.error(
|
|
9841
9969
|
{
|
|
9842
9970
|
error: error instanceof Error ? error.message : error,
|
|
9843
9971
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -9854,12 +9982,12 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
9854
9982
|
);
|
|
9855
9983
|
await sseHelper.complete();
|
|
9856
9984
|
} catch (streamError) {
|
|
9857
|
-
|
|
9985
|
+
logger21.error({ streamError }, "Failed to write error to stream");
|
|
9858
9986
|
}
|
|
9859
9987
|
}
|
|
9860
9988
|
});
|
|
9861
9989
|
} catch (error) {
|
|
9862
|
-
|
|
9990
|
+
logger21.error(
|
|
9863
9991
|
{
|
|
9864
9992
|
error: error instanceof Error ? error.message : error,
|
|
9865
9993
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -9887,7 +10015,7 @@ var chat_default = app2;
|
|
|
9887
10015
|
init_dbClient();
|
|
9888
10016
|
init_logger();
|
|
9889
10017
|
var app3 = new zodOpenapi.OpenAPIHono();
|
|
9890
|
-
var
|
|
10018
|
+
var logger22 = agentsCore.getLogger("chatDataStream");
|
|
9891
10019
|
var chatDataStreamRoute = zodOpenapi.createRoute({
|
|
9892
10020
|
method: "post",
|
|
9893
10021
|
path: "/chat",
|
|
@@ -10004,7 +10132,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
10004
10132
|
});
|
|
10005
10133
|
const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
|
|
10006
10134
|
const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
|
|
10007
|
-
|
|
10135
|
+
logger22.info({ userText, lastUserMessage }, "userText");
|
|
10008
10136
|
const messageSpan = api.trace.getActiveSpan();
|
|
10009
10137
|
if (messageSpan) {
|
|
10010
10138
|
messageSpan.setAttributes({
|
|
@@ -10046,7 +10174,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
10046
10174
|
await streamHelper.writeOperation(errorOp("Unable to process request", "system"));
|
|
10047
10175
|
}
|
|
10048
10176
|
} catch (err) {
|
|
10049
|
-
|
|
10177
|
+
logger22.error({ err }, "Streaming error");
|
|
10050
10178
|
await streamHelper.writeOperation(errorOp("Internal server error", "system"));
|
|
10051
10179
|
} finally {
|
|
10052
10180
|
if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
|
|
@@ -10067,7 +10195,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
10067
10195
|
)
|
|
10068
10196
|
);
|
|
10069
10197
|
} catch (error) {
|
|
10070
|
-
|
|
10198
|
+
logger22.error({ error }, "chatDataStream error");
|
|
10071
10199
|
throw agentsCore.createApiError({
|
|
10072
10200
|
code: "internal_server_error",
|
|
10073
10201
|
message: "Failed to process chat completion"
|
|
@@ -10082,7 +10210,7 @@ init_logger();
|
|
|
10082
10210
|
function createMCPSchema(schema) {
|
|
10083
10211
|
return schema;
|
|
10084
10212
|
}
|
|
10085
|
-
var
|
|
10213
|
+
var logger23 = agentsCore.getLogger("mcp");
|
|
10086
10214
|
var _MockResponseSingleton = class _MockResponseSingleton {
|
|
10087
10215
|
constructor() {
|
|
10088
10216
|
__publicField(this, "mockRes");
|
|
@@ -10137,21 +10265,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
|
|
|
10137
10265
|
id: 0
|
|
10138
10266
|
});
|
|
10139
10267
|
var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
|
|
10140
|
-
|
|
10268
|
+
logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
|
|
10141
10269
|
const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
|
|
10142
10270
|
const mockRes = MockResponseSingleton.getInstance().getMockResponse();
|
|
10143
10271
|
try {
|
|
10144
10272
|
await transport.handleRequest(req, mockRes, spoofInitMessage);
|
|
10145
|
-
|
|
10273
|
+
logger23.info({ sessionId }, "Successfully spoofed initialization");
|
|
10146
10274
|
} catch (spoofError) {
|
|
10147
|
-
|
|
10275
|
+
logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
|
|
10148
10276
|
}
|
|
10149
10277
|
};
|
|
10150
10278
|
var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
10151
10279
|
const sessionId = req.headers["mcp-session-id"];
|
|
10152
|
-
|
|
10280
|
+
logger23.info({ sessionId }, "Received MCP session ID");
|
|
10153
10281
|
if (!sessionId) {
|
|
10154
|
-
|
|
10282
|
+
logger23.info({ body }, "Missing session ID");
|
|
10155
10283
|
res.writeHead(400).end(
|
|
10156
10284
|
JSON.stringify({
|
|
10157
10285
|
jsonrpc: "2.0",
|
|
@@ -10177,7 +10305,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
|
10177
10305
|
scopes: { tenantId, projectId },
|
|
10178
10306
|
conversationId: sessionId
|
|
10179
10307
|
});
|
|
10180
|
-
|
|
10308
|
+
logger23.info(
|
|
10181
10309
|
{
|
|
10182
10310
|
sessionId,
|
|
10183
10311
|
conversationFound: !!conversation,
|
|
@@ -10188,7 +10316,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
|
10188
10316
|
"Conversation lookup result"
|
|
10189
10317
|
);
|
|
10190
10318
|
if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
|
|
10191
|
-
|
|
10319
|
+
logger23.info(
|
|
10192
10320
|
{ sessionId, conversationId: conversation?.id },
|
|
10193
10321
|
"MCP session not found or invalid"
|
|
10194
10322
|
);
|
|
@@ -10249,7 +10377,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
|
|
|
10249
10377
|
requestId: requestId2,
|
|
10250
10378
|
sseHelper: mcpStreamHelper
|
|
10251
10379
|
});
|
|
10252
|
-
|
|
10380
|
+
logger23.info(
|
|
10253
10381
|
{ result },
|
|
10254
10382
|
`Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
|
|
10255
10383
|
);
|
|
@@ -10333,7 +10461,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
|
|
|
10333
10461
|
dbClient: dbClient_default,
|
|
10334
10462
|
credentialStores
|
|
10335
10463
|
});
|
|
10336
|
-
|
|
10464
|
+
logger23.info(
|
|
10337
10465
|
{
|
|
10338
10466
|
tenantId,
|
|
10339
10467
|
projectId,
|
|
@@ -10395,7 +10523,7 @@ var validateRequestParameters = (c) => {
|
|
|
10395
10523
|
};
|
|
10396
10524
|
var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
|
|
10397
10525
|
const { tenantId, projectId, graphId } = executionContext;
|
|
10398
|
-
|
|
10526
|
+
logger23.info({ body }, "Received initialization request");
|
|
10399
10527
|
const sessionId = nanoid.nanoid();
|
|
10400
10528
|
const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
|
|
10401
10529
|
scopes: { tenantId, projectId, graphId }
|
|
@@ -10435,7 +10563,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
10435
10563
|
}
|
|
10436
10564
|
}
|
|
10437
10565
|
});
|
|
10438
|
-
|
|
10566
|
+
logger23.info(
|
|
10439
10567
|
{ sessionId, conversationId: conversation.id },
|
|
10440
10568
|
"Created MCP session as conversation"
|
|
10441
10569
|
);
|
|
@@ -10444,9 +10572,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
10444
10572
|
});
|
|
10445
10573
|
const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
|
|
10446
10574
|
await server.connect(transport);
|
|
10447
|
-
|
|
10575
|
+
logger23.info({ sessionId }, "Server connected for initialization");
|
|
10448
10576
|
res.setHeader("Mcp-Session-Id", sessionId);
|
|
10449
|
-
|
|
10577
|
+
logger23.info(
|
|
10450
10578
|
{
|
|
10451
10579
|
sessionId,
|
|
10452
10580
|
bodyMethod: body?.method,
|
|
@@ -10455,7 +10583,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
10455
10583
|
"About to handle initialization request"
|
|
10456
10584
|
);
|
|
10457
10585
|
await transport.handleRequest(req, res, body);
|
|
10458
|
-
|
|
10586
|
+
logger23.info({ sessionId }, "Successfully handled initialization request");
|
|
10459
10587
|
return fetchToNode.toFetchResponse(res);
|
|
10460
10588
|
};
|
|
10461
10589
|
var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
|
|
@@ -10483,8 +10611,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
|
|
|
10483
10611
|
sessionId,
|
|
10484
10612
|
conversation.metadata?.session_data?.mcpProtocolVersion
|
|
10485
10613
|
);
|
|
10486
|
-
|
|
10487
|
-
|
|
10614
|
+
logger23.info({ sessionId }, "Server connected and transport initialized");
|
|
10615
|
+
logger23.info(
|
|
10488
10616
|
{
|
|
10489
10617
|
sessionId,
|
|
10490
10618
|
bodyKeys: Object.keys(body || {}),
|
|
@@ -10498,9 +10626,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
|
|
|
10498
10626
|
);
|
|
10499
10627
|
try {
|
|
10500
10628
|
await transport.handleRequest(req, res, body);
|
|
10501
|
-
|
|
10629
|
+
logger23.info({ sessionId }, "Successfully handled MCP request");
|
|
10502
10630
|
} catch (transportError) {
|
|
10503
|
-
|
|
10631
|
+
logger23.error(
|
|
10504
10632
|
{
|
|
10505
10633
|
sessionId,
|
|
10506
10634
|
error: transportError,
|
|
@@ -10551,13 +10679,13 @@ app4.openapi(
|
|
|
10551
10679
|
}
|
|
10552
10680
|
const { executionContext } = paramValidation;
|
|
10553
10681
|
const body = c.get("requestBody") || {};
|
|
10554
|
-
|
|
10682
|
+
logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
|
|
10555
10683
|
const isInitRequest = body.method === "initialize";
|
|
10556
10684
|
const { req, res } = fetchToNode.toReqRes(c.req.raw);
|
|
10557
10685
|
const validatedContext = c.get("validatedContext") || {};
|
|
10558
10686
|
const credentialStores = c.get("credentialStores");
|
|
10559
|
-
|
|
10560
|
-
|
|
10687
|
+
logger23.info({ validatedContext }, "Validated context");
|
|
10688
|
+
logger23.info({ req }, "request");
|
|
10561
10689
|
if (isInitRequest) {
|
|
10562
10690
|
return await handleInitializationRequest(
|
|
10563
10691
|
body,
|
|
@@ -10579,7 +10707,7 @@ app4.openapi(
|
|
|
10579
10707
|
);
|
|
10580
10708
|
}
|
|
10581
10709
|
} catch (e) {
|
|
10582
|
-
|
|
10710
|
+
logger23.error(
|
|
10583
10711
|
{
|
|
10584
10712
|
error: e instanceof Error ? e.message : e,
|
|
10585
10713
|
stack: e instanceof Error ? e.stack : void 0
|
|
@@ -10591,7 +10719,7 @@ app4.openapi(
|
|
|
10591
10719
|
}
|
|
10592
10720
|
);
|
|
10593
10721
|
app4.get("/", async (c) => {
|
|
10594
|
-
|
|
10722
|
+
logger23.info({}, "Received GET MCP request");
|
|
10595
10723
|
return c.json(
|
|
10596
10724
|
{
|
|
10597
10725
|
jsonrpc: "2.0",
|
|
@@ -10605,7 +10733,7 @@ app4.get("/", async (c) => {
|
|
|
10605
10733
|
);
|
|
10606
10734
|
});
|
|
10607
10735
|
app4.delete("/", async (c) => {
|
|
10608
|
-
|
|
10736
|
+
logger23.info({}, "Received DELETE MCP request");
|
|
10609
10737
|
return c.json(
|
|
10610
10738
|
{
|
|
10611
10739
|
jsonrpc: "2.0",
|
|
@@ -10618,7 +10746,7 @@ app4.delete("/", async (c) => {
|
|
|
10618
10746
|
var mcp_default = app4;
|
|
10619
10747
|
|
|
10620
10748
|
// src/app.ts
|
|
10621
|
-
var
|
|
10749
|
+
var logger24 = agentsCore.getLogger("agents-run-api");
|
|
10622
10750
|
function createExecutionHono(serverConfig, credentialStores) {
|
|
10623
10751
|
const app6 = new zodOpenapi.OpenAPIHono();
|
|
10624
10752
|
app6.use("*", otel.otel());
|
|
@@ -10634,7 +10762,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10634
10762
|
const body = await c.req.json();
|
|
10635
10763
|
c.set("requestBody", body);
|
|
10636
10764
|
} catch (error) {
|
|
10637
|
-
|
|
10765
|
+
logger24.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
|
|
10638
10766
|
}
|
|
10639
10767
|
}
|
|
10640
10768
|
return next();
|
|
@@ -10685,8 +10813,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10685
10813
|
if (!isExpectedError) {
|
|
10686
10814
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
10687
10815
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
10688
|
-
if (
|
|
10689
|
-
|
|
10816
|
+
if (logger24) {
|
|
10817
|
+
logger24.error(
|
|
10690
10818
|
{
|
|
10691
10819
|
error: err,
|
|
10692
10820
|
message: errorMessage,
|
|
@@ -10698,8 +10826,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10698
10826
|
);
|
|
10699
10827
|
}
|
|
10700
10828
|
} else {
|
|
10701
|
-
if (
|
|
10702
|
-
|
|
10829
|
+
if (logger24) {
|
|
10830
|
+
logger24.error(
|
|
10703
10831
|
{
|
|
10704
10832
|
error: err,
|
|
10705
10833
|
path: c.req.path,
|
|
@@ -10716,8 +10844,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10716
10844
|
const response = err.getResponse();
|
|
10717
10845
|
return response;
|
|
10718
10846
|
} catch (responseError) {
|
|
10719
|
-
if (
|
|
10720
|
-
|
|
10847
|
+
if (logger24) {
|
|
10848
|
+
logger24.error({ error: responseError }, "Error while handling HTTPException response");
|
|
10721
10849
|
}
|
|
10722
10850
|
}
|
|
10723
10851
|
}
|
|
@@ -10751,7 +10879,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10751
10879
|
app6.use("*", async (c, next) => {
|
|
10752
10880
|
const executionContext = c.get("executionContext");
|
|
10753
10881
|
if (!executionContext) {
|
|
10754
|
-
|
|
10882
|
+
logger24.debug({}, "Empty execution context");
|
|
10755
10883
|
return next();
|
|
10756
10884
|
}
|
|
10757
10885
|
const { tenantId, projectId, graphId } = executionContext;
|
|
@@ -10760,7 +10888,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10760
10888
|
if (requestBody) {
|
|
10761
10889
|
conversationId = requestBody.conversationId;
|
|
10762
10890
|
if (!conversationId) {
|
|
10763
|
-
|
|
10891
|
+
logger24.debug({ requestBody }, "No conversation ID found in request body");
|
|
10764
10892
|
}
|
|
10765
10893
|
}
|
|
10766
10894
|
const entries = Object.fromEntries(
|
|
@@ -10775,7 +10903,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
10775
10903
|
})
|
|
10776
10904
|
);
|
|
10777
10905
|
if (!Object.keys(entries).length) {
|
|
10778
|
-
|
|
10906
|
+
logger24.debug({}, "Empty entries for baggage");
|
|
10779
10907
|
return next();
|
|
10780
10908
|
}
|
|
10781
10909
|
const bag = Object.entries(entries).reduce(
|