@inkeep/agents-run-api 0.19.9 → 0.20.1
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 +71 -59
- package/dist/index.js +71 -59
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3914,12 +3914,12 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
3914
3914
|
case "tool_call": {
|
|
3915
3915
|
activities.push(
|
|
3916
3916
|
`\u{1F527} **${event.data.toolName}** (called)
|
|
3917
|
-
\u{1F4E5} Input: ${JSON.stringify(event.data.
|
|
3917
|
+
\u{1F4E5} Input: ${JSON.stringify(event.data.input)}`
|
|
3918
3918
|
);
|
|
3919
3919
|
break;
|
|
3920
3920
|
}
|
|
3921
3921
|
case "tool_result": {
|
|
3922
|
-
const resultStr = event.data.error ? `\u274C Error: ${event.data.error}` : JSON.stringify(event.data.
|
|
3922
|
+
const resultStr = event.data.error ? `\u274C Error: ${event.data.error}` : JSON.stringify(event.data.output);
|
|
3923
3923
|
activities.push(
|
|
3924
3924
|
`\u{1F527} **${event.data.toolName}** ${event.data.duration ? `(${event.data.duration}ms)` : ""}
|
|
3925
3925
|
\u{1F4E4} Output: ${resultStr}`
|
|
@@ -6164,10 +6164,13 @@ var createTransferToAgentTool = ({
|
|
|
6164
6164
|
fromSubAgentId: callingAgentId
|
|
6165
6165
|
// Include the calling agent ID for tracking
|
|
6166
6166
|
};
|
|
6167
|
-
logger14.info(
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6167
|
+
logger14.info(
|
|
6168
|
+
{
|
|
6169
|
+
transferResult,
|
|
6170
|
+
transferResultKeys: Object.keys(transferResult)
|
|
6171
|
+
},
|
|
6172
|
+
"[DEBUG] Transfer tool returning"
|
|
6173
|
+
);
|
|
6171
6174
|
return transferResult;
|
|
6172
6175
|
}
|
|
6173
6176
|
});
|
|
@@ -6629,7 +6632,7 @@ var Phase1Config = class _Phase1Config {
|
|
|
6629
6632
|
}
|
|
6630
6633
|
let systemPrompt = systemPromptTemplate;
|
|
6631
6634
|
systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
|
|
6632
|
-
const agentContextSection = this.generateAgentContextSection(config.
|
|
6635
|
+
const agentContextSection = this.generateAgentContextSection(config.prompt);
|
|
6633
6636
|
systemPrompt = systemPrompt.replace("{{AGENT_CONTEXT_SECTION}}", agentContextSection);
|
|
6634
6637
|
const toolData = this.isToolDataArray(config.tools) ? config.tools : _Phase1Config.convertMcpToolsToToolData(config.tools);
|
|
6635
6638
|
const hasArtifactComponents = config.artifactComponents && config.artifactComponents.length > 0;
|
|
@@ -6657,13 +6660,13 @@ var Phase1Config = class _Phase1Config {
|
|
|
6657
6660
|
systemPrompt = systemPrompt.replace("{{DELEGATION_INSTRUCTIONS}}", delegationSection);
|
|
6658
6661
|
return systemPrompt;
|
|
6659
6662
|
}
|
|
6660
|
-
generateAgentContextSection(
|
|
6661
|
-
if (!
|
|
6663
|
+
generateAgentContextSection(prompt) {
|
|
6664
|
+
if (!prompt) {
|
|
6662
6665
|
return "";
|
|
6663
6666
|
}
|
|
6664
6667
|
return `
|
|
6665
6668
|
<agent_context>
|
|
6666
|
-
${
|
|
6669
|
+
${prompt}
|
|
6667
6670
|
</agent_context>`;
|
|
6668
6671
|
}
|
|
6669
6672
|
generateThinkingPreparationSection(templates, isThinkingPreparation) {
|
|
@@ -7629,7 +7632,7 @@ var Agent = class {
|
|
|
7629
7632
|
...toolDefinition,
|
|
7630
7633
|
execute: async (args, context) => {
|
|
7631
7634
|
const startTime = Date.now();
|
|
7632
|
-
const
|
|
7635
|
+
const toolCallId = context?.toolCallId || generateToolId();
|
|
7633
7636
|
const activeSpan = api.trace.getActiveSpan();
|
|
7634
7637
|
if (activeSpan) {
|
|
7635
7638
|
activeSpan.setAttributes({
|
|
@@ -7644,9 +7647,8 @@ var Agent = class {
|
|
|
7644
7647
|
if (streamRequestId && !isInternalTool) {
|
|
7645
7648
|
agentSessionManager.recordEvent(streamRequestId, "tool_call", this.config.id, {
|
|
7646
7649
|
toolName,
|
|
7647
|
-
args,
|
|
7648
|
-
toolCallId
|
|
7649
|
-
toolId
|
|
7650
|
+
input: args,
|
|
7651
|
+
toolCallId
|
|
7650
7652
|
});
|
|
7651
7653
|
}
|
|
7652
7654
|
try {
|
|
@@ -7655,9 +7657,8 @@ var Agent = class {
|
|
|
7655
7657
|
if (streamRequestId && !isInternalTool) {
|
|
7656
7658
|
agentSessionManager.recordEvent(streamRequestId, "tool_result", this.config.id, {
|
|
7657
7659
|
toolName,
|
|
7658
|
-
result,
|
|
7659
|
-
toolCallId
|
|
7660
|
-
toolId,
|
|
7660
|
+
output: result,
|
|
7661
|
+
toolCallId,
|
|
7661
7662
|
duration
|
|
7662
7663
|
});
|
|
7663
7664
|
}
|
|
@@ -7668,9 +7669,8 @@ var Agent = class {
|
|
|
7668
7669
|
if (streamRequestId && !isInternalTool) {
|
|
7669
7670
|
agentSessionManager.recordEvent(streamRequestId, "tool_result", this.config.id, {
|
|
7670
7671
|
toolName,
|
|
7671
|
-
|
|
7672
|
-
toolCallId
|
|
7673
|
-
toolId,
|
|
7672
|
+
output: null,
|
|
7673
|
+
toolCallId,
|
|
7674
7674
|
duration,
|
|
7675
7675
|
error: errorMessage
|
|
7676
7676
|
});
|
|
@@ -8146,7 +8146,7 @@ var Agent = class {
|
|
|
8146
8146
|
/**
|
|
8147
8147
|
* Get the agent prompt for this agent's agent
|
|
8148
8148
|
*/
|
|
8149
|
-
async
|
|
8149
|
+
async getPrompt() {
|
|
8150
8150
|
try {
|
|
8151
8151
|
const agentDefinition = await agentsCore.getFullAgentDefinition(dbClient_default)({
|
|
8152
8152
|
scopes: {
|
|
@@ -8207,10 +8207,10 @@ var Agent = class {
|
|
|
8207
8207
|
const hasAgentArtifactComponents = await this.hasAgentArtifactComponents();
|
|
8208
8208
|
const conversationId = runtimeContext?.metadata?.conversationId || runtimeContext?.contextId;
|
|
8209
8209
|
const resolvedContext = conversationId ? await this.getResolvedContext(conversationId) : null;
|
|
8210
|
-
let processedPrompt = this.config.
|
|
8210
|
+
let processedPrompt = this.config.prompt;
|
|
8211
8211
|
if (resolvedContext) {
|
|
8212
8212
|
try {
|
|
8213
|
-
processedPrompt = agentsCore.TemplateEngine.render(this.config.
|
|
8213
|
+
processedPrompt = agentsCore.TemplateEngine.render(this.config.prompt, resolvedContext, {
|
|
8214
8214
|
strict: false,
|
|
8215
8215
|
preserveUnresolved: false
|
|
8216
8216
|
});
|
|
@@ -8222,7 +8222,7 @@ var Agent = class {
|
|
|
8222
8222
|
},
|
|
8223
8223
|
"Failed to process agent prompt with context for Phase 2, using original"
|
|
8224
8224
|
);
|
|
8225
|
-
processedPrompt = this.config.
|
|
8225
|
+
processedPrompt = this.config.prompt;
|
|
8226
8226
|
}
|
|
8227
8227
|
}
|
|
8228
8228
|
const referenceTaskIds = await agentsCore.listTaskIdsByContextId(dbClient_default)({
|
|
@@ -8254,10 +8254,10 @@ var Agent = class {
|
|
|
8254
8254
|
this.setConversationId(conversationId);
|
|
8255
8255
|
}
|
|
8256
8256
|
const resolvedContext = conversationId ? await this.getResolvedContext(conversationId) : null;
|
|
8257
|
-
let processedPrompt = this.config.
|
|
8257
|
+
let processedPrompt = this.config.prompt;
|
|
8258
8258
|
if (resolvedContext) {
|
|
8259
8259
|
try {
|
|
8260
|
-
processedPrompt = agentsCore.TemplateEngine.render(this.config.
|
|
8260
|
+
processedPrompt = agentsCore.TemplateEngine.render(this.config.prompt, resolvedContext, {
|
|
8261
8261
|
strict: false,
|
|
8262
8262
|
preserveUnresolved: false
|
|
8263
8263
|
});
|
|
@@ -8269,7 +8269,7 @@ var Agent = class {
|
|
|
8269
8269
|
},
|
|
8270
8270
|
"Failed to process agent prompt with context, using original"
|
|
8271
8271
|
);
|
|
8272
|
-
processedPrompt = this.config.
|
|
8272
|
+
processedPrompt = this.config.prompt;
|
|
8273
8273
|
}
|
|
8274
8274
|
}
|
|
8275
8275
|
const streamRequestId = runtimeContext?.metadata?.streamRequestId;
|
|
@@ -8308,10 +8308,10 @@ var Agent = class {
|
|
|
8308
8308
|
});
|
|
8309
8309
|
const componentDataComponents = excludeDataComponents ? [] : this.config.dataComponents || [];
|
|
8310
8310
|
const isThinkingPreparation = this.config.dataComponents && this.config.dataComponents.length > 0 && excludeDataComponents;
|
|
8311
|
-
let
|
|
8312
|
-
if (
|
|
8311
|
+
let prompt = await this.getPrompt();
|
|
8312
|
+
if (prompt && resolvedContext) {
|
|
8313
8313
|
try {
|
|
8314
|
-
|
|
8314
|
+
prompt = agentsCore.TemplateEngine.render(prompt, resolvedContext, {
|
|
8315
8315
|
strict: false,
|
|
8316
8316
|
preserveUnresolved: false
|
|
8317
8317
|
});
|
|
@@ -8329,7 +8329,7 @@ var Agent = class {
|
|
|
8329
8329
|
const hasAgentArtifactComponents = await this.hasAgentArtifactComponents();
|
|
8330
8330
|
const config = {
|
|
8331
8331
|
corePrompt: processedPrompt,
|
|
8332
|
-
|
|
8332
|
+
prompt,
|
|
8333
8333
|
tools: toolDefinitions,
|
|
8334
8334
|
dataComponents: componentDataComponents,
|
|
8335
8335
|
artifacts: referenceArtifacts,
|
|
@@ -9274,7 +9274,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9274
9274
|
return relation;
|
|
9275
9275
|
})
|
|
9276
9276
|
);
|
|
9277
|
-
const
|
|
9277
|
+
const prompt = "prompt" in config.agentSchema ? config.agentSchema.prompt : "";
|
|
9278
9278
|
const models = "models" in config.agentSchema ? config.agentSchema.models : void 0;
|
|
9279
9279
|
const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
|
|
9280
9280
|
const toolsForAgentResult = await Promise.all(
|
|
@@ -9292,7 +9292,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9292
9292
|
apiKey: config.apiKey,
|
|
9293
9293
|
name: config.name,
|
|
9294
9294
|
description: config.description || "",
|
|
9295
|
-
|
|
9295
|
+
prompt,
|
|
9296
9296
|
models: models || void 0,
|
|
9297
9297
|
stopWhen: stopWhen || void 0,
|
|
9298
9298
|
subAgentRelations: enhancedInternalRelations.map((relation) => ({
|
|
@@ -9304,7 +9304,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9304
9304
|
apiKey: config.apiKey,
|
|
9305
9305
|
name: relation.name,
|
|
9306
9306
|
description: relation.description,
|
|
9307
|
-
|
|
9307
|
+
prompt: "",
|
|
9308
9308
|
delegateRelations: [],
|
|
9309
9309
|
subAgentRelations: [],
|
|
9310
9310
|
transferRelations: []
|
|
@@ -9318,7 +9318,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9318
9318
|
agentId: config.agentId,
|
|
9319
9319
|
name: relation.name,
|
|
9320
9320
|
description: relation.description,
|
|
9321
|
-
|
|
9321
|
+
prompt: "",
|
|
9322
9322
|
delegateRelations: [],
|
|
9323
9323
|
subAgentRelations: [],
|
|
9324
9324
|
transferRelations: []
|
|
@@ -9336,7 +9336,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9336
9336
|
apiKey: config.apiKey,
|
|
9337
9337
|
name: relation.name,
|
|
9338
9338
|
description: relation.description,
|
|
9339
|
-
|
|
9339
|
+
prompt: "",
|
|
9340
9340
|
delegateRelations: [],
|
|
9341
9341
|
subAgentRelations: [],
|
|
9342
9342
|
transferRelations: []
|
|
@@ -9426,13 +9426,16 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9426
9426
|
const toolResult = allToolResults.find(
|
|
9427
9427
|
(result) => result.toolCallId === toolCall.toolCallId
|
|
9428
9428
|
);
|
|
9429
|
-
logger19.info(
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9429
|
+
logger19.info(
|
|
9430
|
+
{
|
|
9431
|
+
toolCallName: toolCall.toolName,
|
|
9432
|
+
toolCallId: toolCall.toolCallId,
|
|
9433
|
+
hasToolResult: !!toolResult,
|
|
9434
|
+
toolResultOutput: toolResult?.output,
|
|
9435
|
+
toolResultKeys: toolResult?.output ? Object.keys(toolResult.output) : []
|
|
9436
|
+
},
|
|
9437
|
+
"[DEBUG] Transfer tool result found"
|
|
9438
|
+
);
|
|
9436
9439
|
const isValidTransferResult = (output) => {
|
|
9437
9440
|
return typeof output === "object" && output !== null && "type" in output && "targetSubAgentId" in output && output.type === "transfer" && typeof output.targetSubAgentId === "string";
|
|
9438
9441
|
};
|
|
@@ -9440,12 +9443,15 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9440
9443
|
const transferReason = responseText || allThoughts[allThoughts.length - 1]?.text || "Agent requested transfer. No reason provided.";
|
|
9441
9444
|
if (toolResult?.output && isValidTransferResult(toolResult.output)) {
|
|
9442
9445
|
const transferResult = toolResult.output;
|
|
9443
|
-
logger19.info(
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9446
|
+
logger19.info(
|
|
9447
|
+
{
|
|
9448
|
+
validationPassed: true,
|
|
9449
|
+
transferResult,
|
|
9450
|
+
targetSubAgentId: transferResult.targetSubAgentId,
|
|
9451
|
+
fromSubAgentId: transferResult.fromSubAgentId
|
|
9452
|
+
},
|
|
9453
|
+
"[DEBUG] Transfer validation passed, extracted data"
|
|
9454
|
+
);
|
|
9449
9455
|
const artifactData = {
|
|
9450
9456
|
type: "transfer",
|
|
9451
9457
|
targetSubAgentId: transferResult.targetSubAgentId,
|
|
@@ -9454,10 +9460,13 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9454
9460
|
reason: transferReason,
|
|
9455
9461
|
original_message: userMessage
|
|
9456
9462
|
};
|
|
9457
|
-
logger19.info(
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9463
|
+
logger19.info(
|
|
9464
|
+
{
|
|
9465
|
+
artifactData,
|
|
9466
|
+
artifactDataKeys: Object.keys(artifactData)
|
|
9467
|
+
},
|
|
9468
|
+
"[DEBUG] Artifact data being returned"
|
|
9469
|
+
);
|
|
9461
9470
|
return {
|
|
9462
9471
|
status: {
|
|
9463
9472
|
state: agentsCore.TaskState.Completed,
|
|
@@ -9476,12 +9485,15 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
9476
9485
|
]
|
|
9477
9486
|
};
|
|
9478
9487
|
} else {
|
|
9479
|
-
logger19.warn(
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9488
|
+
logger19.warn(
|
|
9489
|
+
{
|
|
9490
|
+
hasToolResult: !!toolResult,
|
|
9491
|
+
hasOutput: !!toolResult?.output,
|
|
9492
|
+
validationPassed: false,
|
|
9493
|
+
output: toolResult?.output
|
|
9494
|
+
},
|
|
9495
|
+
"[DEBUG] Transfer validation FAILED"
|
|
9496
|
+
);
|
|
9485
9497
|
}
|
|
9486
9498
|
}
|
|
9487
9499
|
}
|
package/dist/index.js
CHANGED
|
@@ -2981,12 +2981,12 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2981
2981
|
case "tool_call": {
|
|
2982
2982
|
activities.push(
|
|
2983
2983
|
`\u{1F527} **${event.data.toolName}** (called)
|
|
2984
|
-
\u{1F4E5} Input: ${JSON.stringify(event.data.
|
|
2984
|
+
\u{1F4E5} Input: ${JSON.stringify(event.data.input)}`
|
|
2985
2985
|
);
|
|
2986
2986
|
break;
|
|
2987
2987
|
}
|
|
2988
2988
|
case "tool_result": {
|
|
2989
|
-
const resultStr = event.data.error ? `\u274C Error: ${event.data.error}` : JSON.stringify(event.data.
|
|
2989
|
+
const resultStr = event.data.error ? `\u274C Error: ${event.data.error}` : JSON.stringify(event.data.output);
|
|
2990
2990
|
activities.push(
|
|
2991
2991
|
`\u{1F527} **${event.data.toolName}** ${event.data.duration ? `(${event.data.duration}ms)` : ""}
|
|
2992
2992
|
\u{1F4E4} Output: ${resultStr}`
|
|
@@ -5208,10 +5208,13 @@ var createTransferToAgentTool = ({
|
|
|
5208
5208
|
fromSubAgentId: callingAgentId
|
|
5209
5209
|
// Include the calling agent ID for tracking
|
|
5210
5210
|
};
|
|
5211
|
-
logger13.info(
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5211
|
+
logger13.info(
|
|
5212
|
+
{
|
|
5213
|
+
transferResult,
|
|
5214
|
+
transferResultKeys: Object.keys(transferResult)
|
|
5215
|
+
},
|
|
5216
|
+
"[DEBUG] Transfer tool returning"
|
|
5217
|
+
);
|
|
5215
5218
|
return transferResult;
|
|
5216
5219
|
}
|
|
5217
5220
|
});
|
|
@@ -5671,7 +5674,7 @@ var Phase1Config = class _Phase1Config {
|
|
|
5671
5674
|
}
|
|
5672
5675
|
let systemPrompt = systemPromptTemplate;
|
|
5673
5676
|
systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
|
|
5674
|
-
const agentContextSection = this.generateAgentContextSection(config.
|
|
5677
|
+
const agentContextSection = this.generateAgentContextSection(config.prompt);
|
|
5675
5678
|
systemPrompt = systemPrompt.replace("{{AGENT_CONTEXT_SECTION}}", agentContextSection);
|
|
5676
5679
|
const toolData = this.isToolDataArray(config.tools) ? config.tools : _Phase1Config.convertMcpToolsToToolData(config.tools);
|
|
5677
5680
|
const hasArtifactComponents = config.artifactComponents && config.artifactComponents.length > 0;
|
|
@@ -5699,13 +5702,13 @@ var Phase1Config = class _Phase1Config {
|
|
|
5699
5702
|
systemPrompt = systemPrompt.replace("{{DELEGATION_INSTRUCTIONS}}", delegationSection);
|
|
5700
5703
|
return systemPrompt;
|
|
5701
5704
|
}
|
|
5702
|
-
generateAgentContextSection(
|
|
5703
|
-
if (!
|
|
5705
|
+
generateAgentContextSection(prompt) {
|
|
5706
|
+
if (!prompt) {
|
|
5704
5707
|
return "";
|
|
5705
5708
|
}
|
|
5706
5709
|
return `
|
|
5707
5710
|
<agent_context>
|
|
5708
|
-
${
|
|
5711
|
+
${prompt}
|
|
5709
5712
|
</agent_context>`;
|
|
5710
5713
|
}
|
|
5711
5714
|
generateThinkingPreparationSection(templates, isThinkingPreparation) {
|
|
@@ -6671,7 +6674,7 @@ var Agent = class {
|
|
|
6671
6674
|
...toolDefinition,
|
|
6672
6675
|
execute: async (args, context) => {
|
|
6673
6676
|
const startTime = Date.now();
|
|
6674
|
-
const
|
|
6677
|
+
const toolCallId = context?.toolCallId || generateToolId();
|
|
6675
6678
|
const activeSpan = trace.getActiveSpan();
|
|
6676
6679
|
if (activeSpan) {
|
|
6677
6680
|
activeSpan.setAttributes({
|
|
@@ -6686,9 +6689,8 @@ var Agent = class {
|
|
|
6686
6689
|
if (streamRequestId && !isInternalTool) {
|
|
6687
6690
|
agentSessionManager.recordEvent(streamRequestId, "tool_call", this.config.id, {
|
|
6688
6691
|
toolName,
|
|
6689
|
-
args,
|
|
6690
|
-
toolCallId
|
|
6691
|
-
toolId
|
|
6692
|
+
input: args,
|
|
6693
|
+
toolCallId
|
|
6692
6694
|
});
|
|
6693
6695
|
}
|
|
6694
6696
|
try {
|
|
@@ -6697,9 +6699,8 @@ var Agent = class {
|
|
|
6697
6699
|
if (streamRequestId && !isInternalTool) {
|
|
6698
6700
|
agentSessionManager.recordEvent(streamRequestId, "tool_result", this.config.id, {
|
|
6699
6701
|
toolName,
|
|
6700
|
-
result,
|
|
6701
|
-
toolCallId
|
|
6702
|
-
toolId,
|
|
6702
|
+
output: result,
|
|
6703
|
+
toolCallId,
|
|
6703
6704
|
duration
|
|
6704
6705
|
});
|
|
6705
6706
|
}
|
|
@@ -6710,9 +6711,8 @@ var Agent = class {
|
|
|
6710
6711
|
if (streamRequestId && !isInternalTool) {
|
|
6711
6712
|
agentSessionManager.recordEvent(streamRequestId, "tool_result", this.config.id, {
|
|
6712
6713
|
toolName,
|
|
6713
|
-
|
|
6714
|
-
toolCallId
|
|
6715
|
-
toolId,
|
|
6714
|
+
output: null,
|
|
6715
|
+
toolCallId,
|
|
6716
6716
|
duration,
|
|
6717
6717
|
error: errorMessage
|
|
6718
6718
|
});
|
|
@@ -7188,7 +7188,7 @@ var Agent = class {
|
|
|
7188
7188
|
/**
|
|
7189
7189
|
* Get the agent prompt for this agent's agent
|
|
7190
7190
|
*/
|
|
7191
|
-
async
|
|
7191
|
+
async getPrompt() {
|
|
7192
7192
|
try {
|
|
7193
7193
|
const agentDefinition = await getFullAgentDefinition(dbClient_default)({
|
|
7194
7194
|
scopes: {
|
|
@@ -7249,10 +7249,10 @@ var Agent = class {
|
|
|
7249
7249
|
const hasAgentArtifactComponents = await this.hasAgentArtifactComponents();
|
|
7250
7250
|
const conversationId = runtimeContext?.metadata?.conversationId || runtimeContext?.contextId;
|
|
7251
7251
|
const resolvedContext = conversationId ? await this.getResolvedContext(conversationId) : null;
|
|
7252
|
-
let processedPrompt = this.config.
|
|
7252
|
+
let processedPrompt = this.config.prompt;
|
|
7253
7253
|
if (resolvedContext) {
|
|
7254
7254
|
try {
|
|
7255
|
-
processedPrompt = TemplateEngine.render(this.config.
|
|
7255
|
+
processedPrompt = TemplateEngine.render(this.config.prompt, resolvedContext, {
|
|
7256
7256
|
strict: false,
|
|
7257
7257
|
preserveUnresolved: false
|
|
7258
7258
|
});
|
|
@@ -7264,7 +7264,7 @@ var Agent = class {
|
|
|
7264
7264
|
},
|
|
7265
7265
|
"Failed to process agent prompt with context for Phase 2, using original"
|
|
7266
7266
|
);
|
|
7267
|
-
processedPrompt = this.config.
|
|
7267
|
+
processedPrompt = this.config.prompt;
|
|
7268
7268
|
}
|
|
7269
7269
|
}
|
|
7270
7270
|
const referenceTaskIds = await listTaskIdsByContextId(dbClient_default)({
|
|
@@ -7296,10 +7296,10 @@ var Agent = class {
|
|
|
7296
7296
|
this.setConversationId(conversationId);
|
|
7297
7297
|
}
|
|
7298
7298
|
const resolvedContext = conversationId ? await this.getResolvedContext(conversationId) : null;
|
|
7299
|
-
let processedPrompt = this.config.
|
|
7299
|
+
let processedPrompt = this.config.prompt;
|
|
7300
7300
|
if (resolvedContext) {
|
|
7301
7301
|
try {
|
|
7302
|
-
processedPrompt = TemplateEngine.render(this.config.
|
|
7302
|
+
processedPrompt = TemplateEngine.render(this.config.prompt, resolvedContext, {
|
|
7303
7303
|
strict: false,
|
|
7304
7304
|
preserveUnresolved: false
|
|
7305
7305
|
});
|
|
@@ -7311,7 +7311,7 @@ var Agent = class {
|
|
|
7311
7311
|
},
|
|
7312
7312
|
"Failed to process agent prompt with context, using original"
|
|
7313
7313
|
);
|
|
7314
|
-
processedPrompt = this.config.
|
|
7314
|
+
processedPrompt = this.config.prompt;
|
|
7315
7315
|
}
|
|
7316
7316
|
}
|
|
7317
7317
|
const streamRequestId = runtimeContext?.metadata?.streamRequestId;
|
|
@@ -7350,10 +7350,10 @@ var Agent = class {
|
|
|
7350
7350
|
});
|
|
7351
7351
|
const componentDataComponents = excludeDataComponents ? [] : this.config.dataComponents || [];
|
|
7352
7352
|
const isThinkingPreparation = this.config.dataComponents && this.config.dataComponents.length > 0 && excludeDataComponents;
|
|
7353
|
-
let
|
|
7354
|
-
if (
|
|
7353
|
+
let prompt = await this.getPrompt();
|
|
7354
|
+
if (prompt && resolvedContext) {
|
|
7355
7355
|
try {
|
|
7356
|
-
|
|
7356
|
+
prompt = TemplateEngine.render(prompt, resolvedContext, {
|
|
7357
7357
|
strict: false,
|
|
7358
7358
|
preserveUnresolved: false
|
|
7359
7359
|
});
|
|
@@ -7371,7 +7371,7 @@ var Agent = class {
|
|
|
7371
7371
|
const hasAgentArtifactComponents = await this.hasAgentArtifactComponents();
|
|
7372
7372
|
const config = {
|
|
7373
7373
|
corePrompt: processedPrompt,
|
|
7374
|
-
|
|
7374
|
+
prompt,
|
|
7375
7375
|
tools: toolDefinitions,
|
|
7376
7376
|
dataComponents: componentDataComponents,
|
|
7377
7377
|
artifacts: referenceArtifacts,
|
|
@@ -8316,7 +8316,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8316
8316
|
return relation;
|
|
8317
8317
|
})
|
|
8318
8318
|
);
|
|
8319
|
-
const
|
|
8319
|
+
const prompt = "prompt" in config.agentSchema ? config.agentSchema.prompt : "";
|
|
8320
8320
|
const models = "models" in config.agentSchema ? config.agentSchema.models : void 0;
|
|
8321
8321
|
const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
|
|
8322
8322
|
const toolsForAgentResult = await Promise.all(
|
|
@@ -8334,7 +8334,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8334
8334
|
apiKey: config.apiKey,
|
|
8335
8335
|
name: config.name,
|
|
8336
8336
|
description: config.description || "",
|
|
8337
|
-
|
|
8337
|
+
prompt,
|
|
8338
8338
|
models: models || void 0,
|
|
8339
8339
|
stopWhen: stopWhen || void 0,
|
|
8340
8340
|
subAgentRelations: enhancedInternalRelations.map((relation) => ({
|
|
@@ -8346,7 +8346,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8346
8346
|
apiKey: config.apiKey,
|
|
8347
8347
|
name: relation.name,
|
|
8348
8348
|
description: relation.description,
|
|
8349
|
-
|
|
8349
|
+
prompt: "",
|
|
8350
8350
|
delegateRelations: [],
|
|
8351
8351
|
subAgentRelations: [],
|
|
8352
8352
|
transferRelations: []
|
|
@@ -8360,7 +8360,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8360
8360
|
agentId: config.agentId,
|
|
8361
8361
|
name: relation.name,
|
|
8362
8362
|
description: relation.description,
|
|
8363
|
-
|
|
8363
|
+
prompt: "",
|
|
8364
8364
|
delegateRelations: [],
|
|
8365
8365
|
subAgentRelations: [],
|
|
8366
8366
|
transferRelations: []
|
|
@@ -8378,7 +8378,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8378
8378
|
apiKey: config.apiKey,
|
|
8379
8379
|
name: relation.name,
|
|
8380
8380
|
description: relation.description,
|
|
8381
|
-
|
|
8381
|
+
prompt: "",
|
|
8382
8382
|
delegateRelations: [],
|
|
8383
8383
|
subAgentRelations: [],
|
|
8384
8384
|
transferRelations: []
|
|
@@ -8468,13 +8468,16 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8468
8468
|
const toolResult = allToolResults.find(
|
|
8469
8469
|
(result) => result.toolCallId === toolCall.toolCallId
|
|
8470
8470
|
);
|
|
8471
|
-
logger17.info(
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8471
|
+
logger17.info(
|
|
8472
|
+
{
|
|
8473
|
+
toolCallName: toolCall.toolName,
|
|
8474
|
+
toolCallId: toolCall.toolCallId,
|
|
8475
|
+
hasToolResult: !!toolResult,
|
|
8476
|
+
toolResultOutput: toolResult?.output,
|
|
8477
|
+
toolResultKeys: toolResult?.output ? Object.keys(toolResult.output) : []
|
|
8478
|
+
},
|
|
8479
|
+
"[DEBUG] Transfer tool result found"
|
|
8480
|
+
);
|
|
8478
8481
|
const isValidTransferResult = (output) => {
|
|
8479
8482
|
return typeof output === "object" && output !== null && "type" in output && "targetSubAgentId" in output && output.type === "transfer" && typeof output.targetSubAgentId === "string";
|
|
8480
8483
|
};
|
|
@@ -8482,12 +8485,15 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8482
8485
|
const transferReason = responseText || allThoughts[allThoughts.length - 1]?.text || "Agent requested transfer. No reason provided.";
|
|
8483
8486
|
if (toolResult?.output && isValidTransferResult(toolResult.output)) {
|
|
8484
8487
|
const transferResult = toolResult.output;
|
|
8485
|
-
logger17.info(
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8488
|
+
logger17.info(
|
|
8489
|
+
{
|
|
8490
|
+
validationPassed: true,
|
|
8491
|
+
transferResult,
|
|
8492
|
+
targetSubAgentId: transferResult.targetSubAgentId,
|
|
8493
|
+
fromSubAgentId: transferResult.fromSubAgentId
|
|
8494
|
+
},
|
|
8495
|
+
"[DEBUG] Transfer validation passed, extracted data"
|
|
8496
|
+
);
|
|
8491
8497
|
const artifactData = {
|
|
8492
8498
|
type: "transfer",
|
|
8493
8499
|
targetSubAgentId: transferResult.targetSubAgentId,
|
|
@@ -8496,10 +8502,13 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8496
8502
|
reason: transferReason,
|
|
8497
8503
|
original_message: userMessage
|
|
8498
8504
|
};
|
|
8499
|
-
logger17.info(
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8505
|
+
logger17.info(
|
|
8506
|
+
{
|
|
8507
|
+
artifactData,
|
|
8508
|
+
artifactDataKeys: Object.keys(artifactData)
|
|
8509
|
+
},
|
|
8510
|
+
"[DEBUG] Artifact data being returned"
|
|
8511
|
+
);
|
|
8503
8512
|
return {
|
|
8504
8513
|
status: {
|
|
8505
8514
|
state: TaskState.Completed,
|
|
@@ -8518,12 +8527,15 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
8518
8527
|
]
|
|
8519
8528
|
};
|
|
8520
8529
|
} else {
|
|
8521
|
-
logger17.warn(
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8530
|
+
logger17.warn(
|
|
8531
|
+
{
|
|
8532
|
+
hasToolResult: !!toolResult,
|
|
8533
|
+
hasOutput: !!toolResult?.output,
|
|
8534
|
+
validationPassed: false,
|
|
8535
|
+
output: toolResult?.output
|
|
8536
|
+
},
|
|
8537
|
+
"[DEBUG] Transfer validation FAILED"
|
|
8538
|
+
);
|
|
8527
8539
|
}
|
|
8528
8540
|
}
|
|
8529
8541
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-run-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"traverse": "^0.6.11",
|
|
52
52
|
"ts-pattern": "^5.7.1",
|
|
53
53
|
"zod": "^4.1.11",
|
|
54
|
-
"@inkeep/agents-core": "^0.
|
|
54
|
+
"@inkeep/agents-core": "^0.20.1"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
57
|
"keytar": "^7.9.0"
|