n8n-nodes-tembory 1.0.48 → 1.0.49
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.
|
@@ -1654,7 +1654,11 @@ const buildCurrentTurnFocus = ({ query = '', recentMessages = [], operationalSta
|
|
|
1654
1654
|
all_user_messages_chronological: recall ? userMessagesChronological : undefined,
|
|
1655
1655
|
tool_status: operationalStatus ? {
|
|
1656
1656
|
executed_tools: toolState.names || [],
|
|
1657
|
-
last_successful_tool: toolState.last_successful_tool
|
|
1657
|
+
last_successful_tool: toolState.last_successful_tool ? {
|
|
1658
|
+
name: toolState.last_successful_tool.name,
|
|
1659
|
+
at: toolState.last_successful_tool.at,
|
|
1660
|
+
status: toolState.last_successful_tool.status || (toolState.last_successful_tool.ok === false ? 'failed' : 'ok'),
|
|
1661
|
+
} : null,
|
|
1658
1662
|
failed_by_name: toolState.failed_by_name || {},
|
|
1659
1663
|
} : undefined,
|
|
1660
1664
|
instruction: recall
|
|
@@ -2306,7 +2310,11 @@ const buildContextMessages = ({ payloadFormat, query, userId, profileFacts, work
|
|
|
2306
2310
|
sections.push({
|
|
2307
2311
|
section: 'conversation_frame',
|
|
2308
2312
|
title: 'Conversation frame',
|
|
2309
|
-
value: buildConversationFrame({
|
|
2313
|
+
value: buildConversationFrame({
|
|
2314
|
+
query,
|
|
2315
|
+
recentMessages: compactForAgent ? pruneByLimit(recentMessages || [], Number(adv.agentRecentMessagesLastN || 20)) : recentMessages,
|
|
2316
|
+
workingMemory,
|
|
2317
|
+
}),
|
|
2310
2318
|
});
|
|
2311
2319
|
const currentTurnFocus = buildCurrentTurnFocus({ query, recentMessages, operationalState, workingMemory });
|
|
2312
2320
|
if (currentTurnFocus) {
|
|
@@ -2371,6 +2379,25 @@ const buildContextMessages = ({ payloadFormat, query, userId, profileFacts, work
|
|
|
2371
2379
|
sections,
|
|
2372
2380
|
diagnostics,
|
|
2373
2381
|
};
|
|
2382
|
+
const sectionValue = (name) => {
|
|
2383
|
+
const found = sections.find((section) => section.section === name);
|
|
2384
|
+
return found ? found.value : undefined;
|
|
2385
|
+
};
|
|
2386
|
+
const compactJson = cleanContextValue({
|
|
2387
|
+
kind: 'tembory.agent_context.v1',
|
|
2388
|
+
instruction: includeHeader ? sectionValue('context_header') : undefined,
|
|
2389
|
+
conversation: sectionValue('conversation_frame'),
|
|
2390
|
+
current_turn_focus: sectionValue('current_turn_focus'),
|
|
2391
|
+
action_directive: sectionValue('action_directive'),
|
|
2392
|
+
summary: {
|
|
2393
|
+
vector_facts: sectionValue('summary'),
|
|
2394
|
+
slm: sectionValue('connected_model_summary') || sectionValue('active_summary'),
|
|
2395
|
+
},
|
|
2396
|
+
working_memory: sectionValue('working_memory'),
|
|
2397
|
+
profile: sectionValue('profile_facts'),
|
|
2398
|
+
tools: sectionValue('tool_ledger'),
|
|
2399
|
+
next_action: sectionValue('next_action'),
|
|
2400
|
+
});
|
|
2374
2401
|
const renderCompactSection = (section) => {
|
|
2375
2402
|
if (section.value === null || section.value === undefined)
|
|
2376
2403
|
return `## ${section.title}\n${section.why_null || 'empty'}`;
|
|
@@ -2384,18 +2411,7 @@ const buildContextMessages = ({ payloadFormat, query, userId, profileFacts, work
|
|
|
2384
2411
|
return [{ role: 'system', content: JSON.stringify(audit, null, 2) }];
|
|
2385
2412
|
if (payloadFormat === 'auditBlocks')
|
|
2386
2413
|
return sections.map((section) => ({ role: 'system', content: renderCompactSection(section) }));
|
|
2387
|
-
|
|
2388
|
-
if (section.section === 'summary' && !section.value)
|
|
2389
|
-
return false;
|
|
2390
|
-
if (section.value === null || section.value === undefined)
|
|
2391
|
-
return false;
|
|
2392
|
-
if (Array.isArray(section.value) && section.value.length === 0)
|
|
2393
|
-
return false;
|
|
2394
|
-
if (typeof section.value === 'object' && !Array.isArray(section.value) && Object.keys(section.value).length === 0)
|
|
2395
|
-
return false;
|
|
2396
|
-
return true;
|
|
2397
|
-
});
|
|
2398
|
-
return [{ role: 'system', content: truncate(renderableSections.map(renderCompactSection).join('\n\n'), Number(adv.contextMaxChars || 6000)) }];
|
|
2414
|
+
return [{ role: 'system', content: JSON.stringify(compactJson) }];
|
|
2399
2415
|
}
|
|
2400
2416
|
if (includeSummary) {
|
|
2401
2417
|
const summary = compactStateSections
|
package/package.json
CHANGED