@framers/agentos 0.15.62 → 0.15.64
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/agents/agency/AgencyMemoryManager.d.ts +3 -3
- package/dist/agents/agency/AgencyRegistry.d.ts +1 -1
- package/dist/agents/agency/AgentCommunicationBus.d.ts +2 -2
- package/dist/agents/agency/index.d.ts +6 -6
- package/dist/agents/definitions/AgentCore.d.ts +11 -11
- package/dist/agents/definitions/AgentFactory.d.ts +3 -3
- package/dist/agents/definitions/AgentPoolAgent.d.ts +9 -9
- package/dist/agents/definitions/AgentPoolConfig.d.ts +2 -2
- package/dist/agents/definitions/IAgent.d.ts +4 -4
- package/dist/agents/definitions/IAgentFactory.d.ts +6 -6
- package/dist/api/AgentOS.d.ts +44 -44
- package/dist/api/agent.d.ts +1 -1
- package/dist/api/embedText.d.ts +1 -1
- package/dist/api/hitl.d.ts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/interfaces/IAgentOS.d.ts +16 -16
- package/dist/api/interfaces/IUnifiedAgent.d.ts +3 -3
- package/dist/api/runtime/AgentOSOrchestrator.d.ts +9 -9
- package/dist/api/runtime/CapabilityDiscoveryInitializer.d.ts +9 -9
- package/dist/api/runtime/ExternalToolResultHandler.d.ts +10 -10
- package/dist/api/runtime/GMIChunkTransformer.d.ts +6 -6
- package/dist/api/runtime/RagMemoryInitializer.d.ts +6 -6
- package/dist/api/runtime/SelfImprovementSessionManager.d.ts +4 -4
- package/dist/api/runtime/StreamChunkEmitter.d.ts +2 -2
- package/dist/api/runtime/TaskOutcomeTelemetryManager.d.ts +3 -3
- package/dist/api/runtime/TurnExecutionPipeline.d.ts +12 -12
- package/dist/api/runtime/WorkflowFacade.d.ts +10 -10
- package/dist/api/runtime/externalToolPause.d.ts +2 -2
- package/dist/api/runtime/externalToolRegistry.d.ts +5 -5
- package/dist/api/runtime/global-default.d.ts +1 -1
- package/dist/api/runtime/personaLoaderResolution.d.ts +2 -2
- package/dist/api/runtime/processRequestWithExternalTools.d.ts +4 -4
- package/dist/api/runtime/processRequestWithRegisteredTools.d.ts +7 -7
- package/dist/api/runtime/resumeExternalToolRequestWithRegisteredTools.d.ts +8 -8
- package/dist/api/runtime/tool-emulation/activation.d.ts +1 -1
- package/dist/api/runtime/tool-emulation/history.d.ts +1 -1
- package/dist/api/runtime/tool-emulation/index.d.ts +5 -5
- package/dist/api/runtime/tool-emulation/loop.d.ts +2 -2
- package/dist/api/runtime/tool-emulation/renderer.d.ts +1 -1
- package/dist/api/runtime/toolCallGate.d.ts +2 -2
- package/dist/api/runtime/turn-phases/conversation-history.d.ts +3 -3
- package/dist/api/runtime/turn-phases/long-term-memory.d.ts +4 -4
- package/dist/api/runtime/turn-phases/prompt-profile.d.ts +2 -2
- package/dist/api/runtime/turn-phases/rolling-summary.d.ts +4 -4
- package/dist/api/runtime/turnFinalResponse.d.ts +3 -3
- package/dist/api/server/AgentOSServer.d.ts +1 -1
- package/dist/api/structured/output/IStructuredOutputManager.d.ts +1 -1
- package/dist/api/structured/output/StructuredOutputManager.d.ts +3 -3
- package/dist/api/structured/output/index.d.ts +3 -3
- package/dist/api/types/AgentOSExternalToolRequest.d.ts +1 -1
- package/dist/api/types/AgentOSInput.d.ts +3 -3
- package/dist/api/types/AgentOSResponse.d.ts +6 -6
- package/dist/api/types/OrchestratorConfig.d.ts +11 -11
- package/dist/api/types.d.ts +1 -1
- package/dist/cognition/marketplace/store/Marketplace.d.ts +2 -2
- package/dist/cognition/marketplace/store/index.d.ts +2 -2
- package/dist/cognition/memory/pipeline/lifecycle/IMemoryLifecycleManager.d.ts +5 -5
- package/dist/cognition/memory/pipeline/lifecycle/MemoryLifecycleManager.d.ts +6 -6
- package/dist/cognition/memory/retrieval/graph/knowledge/KnowledgeGraph.d.ts +3 -3
- package/dist/cognition/nlp/ITextProcessor.d.ts +1 -1
- package/dist/cognition/nlp/TextProcessingPipeline.d.ts +2 -2
- package/dist/cognition/nlp/ai_utilities/HybridUtilityAI.d.ts +1 -1
- package/dist/cognition/nlp/ai_utilities/IUtilityAI.d.ts +1 -1
- package/dist/cognition/nlp/ai_utilities/LLMUtilityAI.d.ts +4 -4
- package/dist/cognition/nlp/ai_utilities/StatisticalUtilityAI.d.ts +1 -1
- package/dist/cognition/nlp/ai_utilities/targetSchemaChecks.d.ts +1 -1
- package/dist/cognition/nlp/filters/StopWordFilter.d.ts +3 -3
- package/dist/cognition/nlp/index.d.ts +13 -13
- package/dist/cognition/nlp/language/LanguageService.d.ts +1 -1
- package/dist/cognition/nlp/language/index.d.ts +5 -5
- package/dist/cognition/nlp/language/providers/DeepLTranslationProvider.d.ts +1 -1
- package/dist/cognition/nlp/language/providers/OpenAITranslationProvider.d.ts +1 -1
- package/dist/cognition/nlp/language/providers/WhisperDetectionProvider.d.ts +1 -1
- package/dist/cognition/nlp/lemmatizers/NoOpLemmatizer.d.ts +2 -2
- package/dist/cognition/nlp/lemmatizers/WordNetLemmatizer.d.ts +2 -2
- package/dist/cognition/nlp/normalizers/AccentStripper.d.ts +2 -2
- package/dist/cognition/nlp/normalizers/LowercaseNormalizer.d.ts +2 -2
- package/dist/cognition/nlp/presets.d.ts +1 -1
- package/dist/cognition/nlp/stemmers/NoOpStemmer.d.ts +2 -2
- package/dist/cognition/nlp/stemmers/PorterStemmer.d.ts +2 -2
- package/dist/cognition/nlp/tokenizers/CodeTokenizer.d.ts +2 -2
- package/dist/cognition/nlp/tokenizers/StandardTokenizer.d.ts +2 -2
- package/dist/cognition/rag/EmbeddingManager.d.ts +3 -3
- package/dist/cognition/rag/IRetrievalAugmentor.d.ts +5 -5
- package/dist/cognition/rag/RetrievalAugmentor.d.ts +6 -6
- package/dist/cognition/rag/VectorStoreManager.d.ts +3 -3
- package/dist/cognition/rag/reranking/IRerankerService.d.ts +1 -1
- package/dist/cognition/rag/reranking/RerankerService.d.ts +3 -3
- package/dist/cognition/rag/reranking/index.d.ts +6 -6
- package/dist/cognition/rag/reranking/providers/CohereReranker.d.ts +1 -1
- package/dist/cognition/rag/reranking/providers/LocalCrossEncoderReranker.d.ts +1 -1
- package/dist/cognition/rag/reranking/providers/index.d.ts +2 -2
- package/dist/cognition/rag/vector-search/HnswIndexSidecar.d.ts +1 -1
- package/dist/cognition/rag/vector-search/index.d.ts +2 -2
- package/dist/cognition/rag/vector_stores/InMemoryVectorStore.d.ts +1 -1
- package/dist/cognition/rag/vector_stores/SqlVectorStore.d.ts +1 -1
- package/dist/cognition/substrate/CognitiveMemoryBridge.d.ts +2 -2
- package/dist/cognition/substrate/ConversationHistoryManager.d.ts +3 -3
- package/dist/cognition/substrate/GMI.d.ts +5 -5
- package/dist/cognition/substrate/GMIManager.d.ts +15 -15
- package/dist/cognition/substrate/IGMI.d.ts +12 -12
- package/dist/cognition/substrate/MetapromptExecutor.d.ts +6 -6
- package/dist/cognition/substrate/SentimentTracker.d.ts +5 -5
- package/dist/cognition/substrate/memory/InMemoryWorkingMemory.d.ts +1 -1
- package/dist/cognition/substrate/persona_overlays/PersonaOverlayManager.d.ts +3 -3
- package/dist/cognition/substrate/persona_overlays/PersonaOverlayTypes.d.ts +2 -2
- package/dist/cognition/substrate/personas/IPersonaDefinition.d.ts +3 -3
- package/dist/cognition/substrate/personas/IPersonaLoader.d.ts +1 -1
- package/dist/cognition/substrate/personas/InMemoryPersonaLoader.d.ts +2 -2
- package/dist/cognition/substrate/personas/PersonaLoader.d.ts +2 -2
- package/dist/cognition/substrate/personas/PersonaValidation.d.ts +1 -1
- package/dist/cognition/substrate/personas/definitions/index.d.ts +1 -1
- package/dist/cognition/substrate/personas/personaNormalization.d.ts +1 -1
- package/dist/cognition/substrate/reasoningTraceLimits.d.ts +2 -2
- package/dist/cognition/substrate/toolCallGate.d.ts +1 -1
- package/dist/cognition/substrate/turnContent.d.ts +1 -1
- package/dist/cognition/web-search/WebSearchService.d.ts +1 -1
- package/dist/cognition/web-search/dedup.d.ts +1 -1
- package/dist/cognition/web-search/fusion.d.ts +1 -1
- package/dist/cognition/web-search/index.d.ts +8 -8
- package/dist/cognition/web-search/providers/BraveProvider.d.ts +1 -1
- package/dist/cognition/web-search/providers/FirecrawlProvider.d.ts +1 -1
- package/dist/cognition/web-search/providers/SerperProvider.d.ts +1 -1
- package/dist/cognition/web-search/providers/TavilyProvider.d.ts +1 -1
- package/dist/cognition/web-search/providers/index.d.ts +4 -4
- package/dist/cognition/web-search/types.d.ts +2 -2
- package/dist/core/conversation/ConversationContext.d.ts +71 -12
- package/dist/core/conversation/ConversationContext.d.ts.map +1 -1
- package/dist/core/conversation/ConversationContext.js +313 -39
- package/dist/core/conversation/ConversationContext.js.map +1 -1
- package/dist/core/conversation/ConversationManager.d.ts +2 -2
- package/dist/core/conversation/ConversationMessage.d.ts +3 -3
- package/dist/core/conversation/ILongTermMemoryRetriever.d.ts +1 -1
- package/dist/core/conversation/IRollingSummaryMemorySink.d.ts +1 -1
- package/dist/core/conversation/RollingSummaryCompactor.d.ts +2 -2
- package/dist/core/embeddings/IEmbeddingManager.d.ts +1 -1
- package/dist/core/llm/IPromptEngine.d.ts +6 -6
- package/dist/core/llm/PromptEngine.d.ts +2 -2
- package/dist/core/llm/providers/AIModelProviderManager.d.ts +14 -14
- package/dist/core/llm/providers/errors/AnthropicProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/ClaudeCodeProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/GeminiCLIProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/GeminiProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/OllamaProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/OpenAIProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/OpenRouterProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/RequestyProviderError.d.ts +1 -1
- package/dist/core/llm/providers/implementations/AnthropicProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/ClaudeCodeCLIBridge.d.ts +5 -5
- package/dist/core/llm/providers/implementations/ClaudeCodeProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/GeminiCLIBridge.d.ts +5 -5
- package/dist/core/llm/providers/implementations/GeminiCLIProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/GeminiProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/GroqProvider.d.ts +2 -2
- package/dist/core/llm/providers/implementations/LiteLLMProvider.d.ts +2 -2
- package/dist/core/llm/providers/implementations/MiniMaxProvider.d.ts +2 -2
- package/dist/core/llm/providers/implementations/MistralProvider.d.ts +2 -2
- package/dist/core/llm/providers/implementations/OllamaProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/RequestyProvider.d.ts +1 -1
- package/dist/core/llm/providers/implementations/TogetherProvider.d.ts +2 -2
- package/dist/core/llm/providers/implementations/XAIProvider.d.ts +2 -2
- package/dist/core/llm/providers/implementations/billing-probe-model.d.ts +1 -1
- package/dist/core/llm/routing/IModelRouter.d.ts +3 -3
- package/dist/core/llm/routing/ModelRouter.d.ts +3 -3
- package/dist/core/llm/routing/PolicyAwareRouter.d.ts +3 -3
- package/dist/core/llm/streaming/StreamingBatcher.d.ts +1 -1
- package/dist/core/llm/streaming/StreamingReconstructor.d.ts +2 -2
- package/dist/core/logging/PinoLogger.d.ts +1 -1
- package/dist/core/streaming/AsyncStreamClientBridge.d.ts +2 -2
- package/dist/core/streaming/IStreamClient.d.ts +1 -1
- package/dist/core/streaming/StreamingManager.d.ts +2 -2
- package/dist/core/tools/ITool.d.ts +2 -2
- package/dist/core/tools/IToolOrchestrator.d.ts +7 -7
- package/dist/core/tools/ToolExecutor.d.ts +4 -4
- package/dist/core/tools/ToolOrchestrator.d.ts +8 -8
- package/dist/core/tools/permissions/IToolPermissionManager.d.ts +3 -3
- package/dist/core/tools/permissions/ToolPermissionManager.d.ts +2 -2
- package/dist/core/utils/index.d.ts +1 -1
- package/dist/core/utils/usage/UsageLedger.d.ts +1 -1
- package/dist/core/vector-store/IVectorStoreManager.d.ts +2 -2
- package/dist/extensions/ExtensionLoader.d.ts +2 -2
- package/dist/extensions/ExtensionManager.d.ts +4 -4
- package/dist/extensions/ExtensionRegistry.d.ts +1 -1
- package/dist/extensions/RegistryConfig.d.ts +1 -1
- package/dist/extensions/SharedServiceRegistry.d.ts +1 -1
- package/dist/extensions/events.d.ts +1 -1
- package/dist/extensions/index.d.ts +10 -10
- package/dist/extensions/manifest.d.ts +3 -3
- package/dist/extensions/types.d.ts +8 -8
- package/dist/index.d.ts +72 -72
- package/dist/io/channels/social-posting/index.d.ts +3 -3
- package/dist/io/hearing/AdaptiveVAD.d.ts +1 -1
- package/dist/io/hearing/AudioProcessor.d.ts +2 -2
- package/dist/io/hearing/SilenceDetector.d.ts +1 -1
- package/dist/io/media/images/PolicyAwareImageRouter.d.ts +1 -1
- package/dist/orchestration/hitl/HumanInteractionManager.d.ts +2 -2
- package/dist/orchestration/hitl/index.d.ts +2 -2
- package/dist/orchestration/planner/IPlanningEngine.d.ts +1 -1
- package/dist/orchestration/planner/PlanningEngine.d.ts +3 -3
- package/dist/orchestration/planner/index.d.ts +2 -2
- package/dist/orchestration/turn-planner/IAgentOrchestrator.d.ts +2 -2
- package/dist/orchestration/turn-planner/TurnPlanner.d.ts +4 -4
- package/dist/orchestration/turn-planner/helpers.d.ts +2 -2
- package/dist/orchestration/workflows/IWorkflowEngine.d.ts +4 -4
- package/dist/orchestration/workflows/WorkflowEngine.d.ts +3 -3
- package/dist/orchestration/workflows/WorkflowTypes.d.ts +2 -2
- package/dist/orchestration/workflows/runtime/WorkflowRuntime.d.ts +9 -9
- package/dist/orchestration/workflows/storage/IWorkflowStore.d.ts +1 -1
- package/dist/orchestration/workflows/storage/InMemoryWorkflowStore.d.ts +2 -2
- package/dist/safety/evaluation/Evaluator.d.ts +1 -1
- package/dist/safety/evaluation/LLMJudge.d.ts +3 -3
- package/dist/safety/evaluation/index.d.ts +4 -4
- package/dist/safety/evaluation/observability/Tracer.d.ts +1 -1
- package/dist/safety/evaluation/observability/index.d.ts +5 -5
- package/dist/safety/guardrails/ICrossAgentGuardrailService.d.ts +2 -2
- package/dist/safety/guardrails/IGuardrailService.d.ts +3 -3
- package/dist/safety/guardrails/ParallelGuardrailDispatcher.d.ts +4 -4
- package/dist/safety/guardrails/builtin/PhraseListGuardrail.d.ts +4 -4
- package/dist/safety/guardrails/crossAgentGuardrailDispatcher.d.ts +4 -4
- package/dist/safety/guardrails/guardrailDispatcher.d.ts +4 -4
- package/dist/safety/guardrails/index.d.ts +8 -8
- package/dist/safety/guardrails/requiredGuardrails.d.ts +1 -1
- package/dist/safety/guardrails/sanitizedFinalResponse.d.ts +3 -3
- package/dist/safety/sandbox/executor/CodeSandbox.d.ts +2 -2
- package/dist/safety/sandbox/executor/ICodeSandbox.d.ts +1 -1
- package/dist/safety/sandbox/executor/index.d.ts +3 -3
- package/dist/safety/sandbox/subprocess/CLISubprocessBridge.d.ts +2 -2
- package/dist/safety/sandbox/subprocess/index.d.ts +4 -4
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @see ../ai_utilities/IUtilityAI.ts For IUtilityAI and SummarizationOptions definitions.
|
|
11
11
|
*/
|
|
12
12
|
import { MessageRole, createConversationMessage } from './ConversationMessage.js';
|
|
13
|
+
import { toolRoundBounds } from './toolRounds.js';
|
|
13
14
|
import { uuidv4 } from '../utils/uuid.js';
|
|
14
15
|
import { GMIError, GMIErrorCode } from '../utils/errors.js'; // Corrected path
|
|
15
16
|
// Constants for summarization logic
|
|
@@ -17,8 +18,135 @@ const DEFAULT_MAX_HISTORY_MESSAGES = 100;
|
|
|
17
18
|
const DEFAULT_VERBATIM_TAIL_COUNT = 10;
|
|
18
19
|
const DEFAULT_VERBATIM_HEAD_COUNT = 2;
|
|
19
20
|
const DEFAULT_SUMMARIZATION_CHUNK_SIZE = 20; // Messages to group for one summary
|
|
21
|
+
const MIN_SUMMARIZATION_CHUNK_SIZE = 2; // A summary of fewer messages could not shorten the history
|
|
20
22
|
const MIN_MESSAGES_FOR_SUMMARIZATION_ATTEMPT = 5; // Don't try to summarize too few messages
|
|
21
23
|
const DEFAULT_SUMMARIZATION_OPTIONS = { desiredLength: 'medium', method: 'abstractive_llm' };
|
|
24
|
+
/**
|
|
25
|
+
* Where to cut `messages` to keep their first `headCount` and their last `tailCount` messages. Providers refuse a tool
|
|
26
|
+
* call without its result and a tool result without its call, so neither cut falls inside a tool round (an assistant
|
|
27
|
+
* message that names tool calls, the tool messages that answer them and anything between, as `toolRoundBounds` finds
|
|
28
|
+
* them): a round the head reaches into is kept whole in the head, and a round the tail reaches into is kept whole in
|
|
29
|
+
* the tail. When that keeps more than `headCount` or `tailCount` messages, the round is kept whole anyway, as the
|
|
30
|
+
* prompt engine's token trim (`PromptEngine.truncateMessages`) keeps a round it cannot drop.
|
|
31
|
+
*
|
|
32
|
+
* @param messages - The messages, oldest first.
|
|
33
|
+
* @param headCount - How many of the first messages to keep.
|
|
34
|
+
* @param tailCount - How many of the last messages to keep.
|
|
35
|
+
* @param rounds - The tool rounds of `messages`, when the caller has them.
|
|
36
|
+
* @returns `headEnd`, the index after the kept head, and `tailStart`, the index of the kept tail's first message, never
|
|
37
|
+
* before `headEnd`. The cut leaves out the messages between them, none when the two are equal.
|
|
38
|
+
*/
|
|
39
|
+
function cutsKeepingToolRounds(messages, headCount, tailCount, rounds) {
|
|
40
|
+
const head = Math.min(Math.floor(Math.max(0, headCount)), messages.length);
|
|
41
|
+
const tail = Math.min(Math.floor(Math.max(0, tailCount)), messages.length);
|
|
42
|
+
if (head + tail >= messages.length) {
|
|
43
|
+
return { headEnd: messages.length, tailStart: messages.length };
|
|
44
|
+
}
|
|
45
|
+
const bounds = rounds ?? toolRoundBounds(messages);
|
|
46
|
+
const headEnd = head > 0 ? bounds.end[head - 1] + 1 : 0;
|
|
47
|
+
const tailStart = tail > 0 ? bounds.start[messages.length - tail] : messages.length;
|
|
48
|
+
return { headEnd, tailStart: Math.max(headEnd, tailStart) };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Whether the tool round that ends `messages` waits for a result: an assistant message in it names a call that no tool
|
|
52
|
+
* message after it answers. A tool message answers the nearest assistant message before it that names its call id, as
|
|
53
|
+
* `toolRoundBounds` reads them.
|
|
54
|
+
*
|
|
55
|
+
* @param messages - The messages, oldest first.
|
|
56
|
+
* @param rounds - The tool rounds of `messages`.
|
|
57
|
+
* @returns True when a call of the last round has no result yet.
|
|
58
|
+
*/
|
|
59
|
+
function lastRoundWaitsForResults(messages, rounds) {
|
|
60
|
+
const last = messages.length - 1;
|
|
61
|
+
if (last < 0)
|
|
62
|
+
return false;
|
|
63
|
+
// each call id of the round by the nearest assistant message that names it, and the calls no result answers yet
|
|
64
|
+
const callerOf = new Map();
|
|
65
|
+
const unanswered = new Set();
|
|
66
|
+
for (let index = rounds.start[last]; index <= last; index += 1) {
|
|
67
|
+
const message = messages[index];
|
|
68
|
+
const calls = message.role === MessageRole.ASSISTANT ? message.tool_calls : undefined;
|
|
69
|
+
if (Array.isArray(calls) && calls.length > 0) {
|
|
70
|
+
for (const call of calls) {
|
|
71
|
+
const callId = call?.id;
|
|
72
|
+
if (typeof callId === 'string' && callId) {
|
|
73
|
+
callerOf.set(callId, index);
|
|
74
|
+
unanswered.add(`${index} ${callId}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (message.role === MessageRole.TOOL && typeof message.tool_call_id === 'string') {
|
|
79
|
+
const caller = callerOf.get(message.tool_call_id);
|
|
80
|
+
if (caller !== undefined)
|
|
81
|
+
unanswered.delete(`${caller} ${message.tool_call_id}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return unanswered.size > 0;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The messages a summary can take its chunk from: those after the first `headCount` and before the last `tailCount`,
|
|
88
|
+
* each cut moved to keep a tool round whole, as `cutsKeepingToolRounds` moves it. A round that ends `messages` and
|
|
89
|
+
* waits for a result stays out too, as a tail of one or more keeps it: its results are recorded later, and a summary of
|
|
90
|
+
* its call would leave them without it. The runtime records nothing after a pause's call until each of its calls is
|
|
91
|
+
* answered (a new turn answers them as not run before it records its input), so a round that waits is the last one.
|
|
92
|
+
* A call followed by other messages before its results, which no provider accepts and the runtime never records, is
|
|
93
|
+
* cut as any other round: a cut cannot tell a call still waiting from one never answered, which a conversation stored
|
|
94
|
+
* before pauses were answered can hold, and holding such calls out of every cut would keep them for good.
|
|
95
|
+
*
|
|
96
|
+
* @param messages - The messages, oldest first.
|
|
97
|
+
* @param headCount - How many of the first messages to keep.
|
|
98
|
+
* @param tailCount - How many of the last messages to keep.
|
|
99
|
+
* @param rounds - The tool rounds of `messages`, when the caller has them.
|
|
100
|
+
* @returns `start`, the index of the first message a summary can take, and `end`, the index after the last. None when
|
|
101
|
+
* `end` is not after `start`.
|
|
102
|
+
*/
|
|
103
|
+
function summaryMiddle(messages, headCount, tailCount, rounds = toolRoundBounds(messages)) {
|
|
104
|
+
const { headEnd, tailStart } = cutsKeepingToolRounds(messages, headCount, tailCount, rounds);
|
|
105
|
+
const end = lastRoundWaitsForResults(messages, rounds)
|
|
106
|
+
? Math.min(tailStart, rounds.start[messages.length - 1])
|
|
107
|
+
: tailStart;
|
|
108
|
+
return { start: headEnd, end };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The messages a trim keeps, in their order.
|
|
112
|
+
*
|
|
113
|
+
* @param messages - The messages, oldest first.
|
|
114
|
+
* @param cuts - Where the trim cuts them.
|
|
115
|
+
* @returns The kept messages.
|
|
116
|
+
*/
|
|
117
|
+
function keptByTrim(messages, cuts) {
|
|
118
|
+
return [
|
|
119
|
+
...messages.slice(0, cuts.headEnd),
|
|
120
|
+
...cuts.summaryIndexes.map((index) => messages[index]),
|
|
121
|
+
...messages.slice(cuts.tailStart),
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A history setting read as a number of messages: the whole part of the number it reads as, never below 0, and
|
|
126
|
+
* `fallback` when it reads as none. A number, or a string that holds one, reads as that number; anything else (given
|
|
127
|
+
* as undefined, null, a blank string, NaN, or a value of another type) reads as none, since `Number()` would read null,
|
|
128
|
+
* a blank string and false as 0.
|
|
129
|
+
*
|
|
130
|
+
* @param value - The setting.
|
|
131
|
+
* @param fallback - The setting's default.
|
|
132
|
+
* @returns The number of messages.
|
|
133
|
+
*/
|
|
134
|
+
function messageCount(value, fallback) {
|
|
135
|
+
if (typeof value !== 'number' && (typeof value !== 'string' || value.trim() === ''))
|
|
136
|
+
return fallback;
|
|
137
|
+
const count = Number(value);
|
|
138
|
+
return Number.isNaN(count) ? fallback : Math.max(0, Math.floor(count));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Whether `message` is a tool call (an assistant message that names calls) or a tool result.
|
|
142
|
+
*
|
|
143
|
+
* @param message - The message.
|
|
144
|
+
* @returns True for a call or a result.
|
|
145
|
+
*/
|
|
146
|
+
function isCallOrResult(message) {
|
|
147
|
+
return (message.role === MessageRole.TOOL ||
|
|
148
|
+
(message.role === MessageRole.ASSISTANT && Array.isArray(message.tool_calls) && message.tool_calls.length > 0));
|
|
149
|
+
}
|
|
22
150
|
/**
|
|
23
151
|
* @class ConversationContext
|
|
24
152
|
* @description Manages the messages, metadata, and operational state for a single conversation.
|
|
@@ -42,6 +170,14 @@ export class ConversationContext {
|
|
|
42
170
|
* @type {boolean}
|
|
43
171
|
*/
|
|
44
172
|
this.isSummarizing = false;
|
|
173
|
+
/**
|
|
174
|
+
* The passes of `manageHistoryLength()` that found a summary being made. Each runs once it is made, so the messages
|
|
175
|
+
* recorded meanwhile get the passes they started: the pass that made the summary runs them, and leaves the rest to
|
|
176
|
+
* one that starts another summary before they have all run.
|
|
177
|
+
* @private
|
|
178
|
+
* @type {number}
|
|
179
|
+
*/
|
|
180
|
+
this.deferredHistoryPasses = 0;
|
|
45
181
|
this.sessionId = sessionId || `conv_ctx_${uuidv4()}`;
|
|
46
182
|
this.createdAt = Date.now();
|
|
47
183
|
this.messages = initialMessages.map(m => ({
|
|
@@ -66,6 +202,14 @@ export class ConversationContext {
|
|
|
66
202
|
...(config.summarizationOptions || {}),
|
|
67
203
|
},
|
|
68
204
|
};
|
|
205
|
+
// The history's cuts index the messages with these settings, so each is read as a whole number of messages, and a
|
|
206
|
+
// setting given as undefined, which the spread above puts in place of its default, keeps the default. A summary
|
|
207
|
+
// takes the place of the messages it summarizes, so its chunk is two messages or more: a summary of fewer would
|
|
208
|
+
// leave the history as long as it was, or make it longer.
|
|
209
|
+
this.config.maxHistoryLengthMessages = messageCount(this.config.maxHistoryLengthMessages, DEFAULT_MAX_HISTORY_MESSAGES);
|
|
210
|
+
this.config.messagesToKeepVerbatimTail = messageCount(this.config.messagesToKeepVerbatimTail, DEFAULT_VERBATIM_TAIL_COUNT);
|
|
211
|
+
this.config.messagesToKeepVerbatimHead = messageCount(this.config.messagesToKeepVerbatimHead, DEFAULT_VERBATIM_HEAD_COUNT);
|
|
212
|
+
this.config.summarizationChunkSize = Math.max(MIN_SUMMARIZATION_CHUNK_SIZE, messageCount(this.config.summarizationChunkSize, DEFAULT_SUMMARIZATION_CHUNK_SIZE));
|
|
69
213
|
this.utilityAI = this.config.utilityAI; // Use the one from the fully merged config
|
|
70
214
|
this.sessionMetadata = { ...initialMetadata };
|
|
71
215
|
// Set well-known metadata from config if present
|
|
@@ -112,9 +256,17 @@ export class ConversationContext {
|
|
|
112
256
|
* Retrieves a portion of the conversation history, optionally limited and filtered.
|
|
113
257
|
* Returns readonly copies of the messages to prevent external modification.
|
|
114
258
|
*
|
|
259
|
+
* With `limit`, the newest `limit` messages. Without it, the messages a trim to `maxHistoryLengthMessages` keeps:
|
|
260
|
+
* the first `messagesToKeepVerbatimHead`, the summary right after them and the last summary after them, and the
|
|
261
|
+
* newest, `maxHistoryLengthMessages` in all, or every message when it is 0. Providers refuse a tool call without its
|
|
262
|
+
* result and a tool result without its call, so neither cut falls inside a tool round (an assistant message that
|
|
263
|
+
* names tool calls, the tool messages that answer them and anything between): a round the returned messages reach
|
|
264
|
+
* into is returned whole, past the limit when it has to be, as the prompt engine's token trim keeps a round it cannot
|
|
265
|
+
* drop.
|
|
266
|
+
*
|
|
115
267
|
* @public
|
|
116
|
-
* @param {number} [limit] - Optional. The
|
|
117
|
-
* @param {MessageRole[]} [excludeRoles] - Optional. An array of message roles to exclude from the returned history.
|
|
268
|
+
* @param {number} [limit] - Optional. The number of recent messages to return, more when the oldest of them is part of a tool round. Without it, the messages a trim to `config.maxHistoryLengthMessages` keeps.
|
|
269
|
+
* @param {MessageRole[]} [excludeRoles] - Optional. An array of message roles to exclude from the returned history. A tool round that loses a call or a result to them loses its other calls and results too, since a provider refuses a call without its results and a result without its call. The other messages are the ones counted.
|
|
118
270
|
* @returns {ReadonlyArray<Readonly<ConversationMessage>>} A readonly array of readonly message objects.
|
|
119
271
|
*/
|
|
120
272
|
getHistory(limit, excludeRoles) {
|
|
@@ -122,11 +274,32 @@ export class ConversationContext {
|
|
|
122
274
|
let effectiveMessages = this.messages;
|
|
123
275
|
if (excludeRoles && excludeRoles.length > 0) {
|
|
124
276
|
const rolesToExclude = new Set(excludeRoles);
|
|
125
|
-
|
|
277
|
+
// A call left out would leave its results without it and a result left out its call, so a tool round that loses
|
|
278
|
+
// a call or a result loses its other calls and results too. A message of another role leaves the round whole.
|
|
279
|
+
const rounds = toolRoundBounds(this.messages);
|
|
280
|
+
const brokenRounds = new Set();
|
|
281
|
+
this.messages.forEach((message, index) => {
|
|
282
|
+
if (rolesToExclude.has(message.role) && isCallOrResult(message) && rounds.start[index] < rounds.end[index]) {
|
|
283
|
+
brokenRounds.add(rounds.start[index]);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
effectiveMessages = this.messages.filter((message, index) => !rolesToExclude.has(message.role) && !(isCallOrResult(message) && brokenRounds.has(rounds.start[index])));
|
|
287
|
+
}
|
|
288
|
+
let returned = effectiveMessages;
|
|
289
|
+
if (limit !== undefined && limit > 0) {
|
|
290
|
+
// the newest `limit` messages, from the first message of a tool round they reach into
|
|
291
|
+
const count = Math.floor(limit);
|
|
292
|
+
if (count > 0 && count < effectiveMessages.length) {
|
|
293
|
+
returned = effectiveMessages.slice(toolRoundBounds(effectiveMessages).start[effectiveMessages.length - count]);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
else if (this.config.maxHistoryLengthMessages > 0) {
|
|
297
|
+
const cuts = this.trimCuts(effectiveMessages, this.config.maxHistoryLengthMessages);
|
|
298
|
+
if (cuts.headEnd < cuts.tailStart)
|
|
299
|
+
returned = keptByTrim(effectiveMessages, cuts);
|
|
126
300
|
}
|
|
127
|
-
const actualLimit = limit !== undefined && limit > 0 ? limit : this.config.maxHistoryLengthMessages;
|
|
128
301
|
// Ensure both array and its elements are treated as readonly
|
|
129
|
-
return Object.freeze(
|
|
302
|
+
return Object.freeze(returned.map(m => Object.freeze({ ...m })));
|
|
130
303
|
}
|
|
131
304
|
/**
|
|
132
305
|
* Retrieves all messages in the conversation.
|
|
@@ -276,13 +449,34 @@ export class ConversationContext {
|
|
|
276
449
|
* it attempts to summarize older messages. Otherwise, it falls back to simple truncation.
|
|
277
450
|
* This method is called asynchronously after each new message is added.
|
|
278
451
|
*
|
|
452
|
+
* A summary replaces a chunk of the messages between the first `messagesToKeepVerbatimHead` and the newest
|
|
453
|
+
* `messagesToKeepVerbatimTail`. None of the three ends inside a tool round: a round the head or the tail reaches into
|
|
454
|
+
* stays whole there, and a round the chunk reaches into is summarized whole, past `summarizationChunkSize`. A round
|
|
455
|
+
* that ends the history and waits for a result stays out of the chunk, with a tail of 0 too: a summary of its call
|
|
456
|
+
* would leave the results recorded later without it. The summary takes the chunk's place, so a message recorded while
|
|
457
|
+
* the summary is made stays after it. The summary of a history cleared meanwhile is dropped, and so is one whose
|
|
458
|
+
* chunk a result recorded meanwhile reaches into (a result for a call in the chunk, recorded after other messages):
|
|
459
|
+
* the pass that result started keeps the round whole. A summary whose chunk holds a message rewritten meanwhile (an
|
|
460
|
+
* output guardrail rewrites a stored reply through `replaceMessageContent()`) is dropped too, and made again from the
|
|
461
|
+
* message as it is. A history still past its limit with too few messages left for another chunk, the ones
|
|
462
|
+
* recorded meanwhile counted in, is trimmed, and the trim keeps this summary, and the last summary after it when a
|
|
463
|
+
* conversation loaded from storage holds one. One with enough left for another chunk waits for the next pass. A pass
|
|
464
|
+
* that finds a summary being made runs once it is made, so the messages recorded meanwhile, after a clear too, get
|
|
465
|
+
* their passes; a summary started before they have all run takes the rest.
|
|
466
|
+
*
|
|
279
467
|
* @private
|
|
280
468
|
* @async
|
|
281
469
|
* @returns {Promise<void>}
|
|
282
470
|
*/
|
|
283
471
|
async manageHistoryLength() {
|
|
284
|
-
|
|
285
|
-
|
|
472
|
+
// A limit of 0 keeps every message, as getHistory() returns them all.
|
|
473
|
+
if (this.config.maxHistoryLengthMessages <= 0 || this.messages.length <= this.config.maxHistoryLengthMessages) {
|
|
474
|
+
return; // No limit, or already within limits
|
|
475
|
+
}
|
|
476
|
+
if (this.isSummarizing) {
|
|
477
|
+
// A summary is being made: this pass runs once it is made.
|
|
478
|
+
this.deferredHistoryPasses += 1;
|
|
479
|
+
return;
|
|
286
480
|
}
|
|
287
481
|
if (this.config.enableAutomaticSummarization && this.utilityAI) {
|
|
288
482
|
this.isSummarizing = true;
|
|
@@ -294,20 +488,47 @@ export class ConversationContext {
|
|
|
294
488
|
this.truncateHistorySimple(this.config.maxHistoryLengthMessages);
|
|
295
489
|
return; // Exit after simple truncation
|
|
296
490
|
}
|
|
297
|
-
// Ensure there's a middle section to process
|
|
298
|
-
|
|
299
|
-
const
|
|
491
|
+
// Ensure there's a middle section to process. It starts after the kept head and ends before the kept tail, each
|
|
492
|
+
// moved to keep a tool round whole, and before a round that ends the history and waits for a result.
|
|
493
|
+
const messages = this.messages;
|
|
494
|
+
const rounds = toolRoundBounds(messages);
|
|
495
|
+
const { start: middleSectionStartIndex, end: middleSectionEndIndex } = summaryMiddle(messages, headCount, tailCount, rounds);
|
|
300
496
|
if (middleSectionStartIndex >= middleSectionEndIndex) {
|
|
301
497
|
this.truncateHistorySimple(this.config.maxHistoryLengthMessages); // Not enough messages for a middle section
|
|
302
498
|
return;
|
|
303
499
|
}
|
|
304
|
-
const
|
|
305
|
-
if (
|
|
306
|
-
|
|
500
|
+
const middleSectionLength = middleSectionEndIndex - middleSectionStartIndex;
|
|
501
|
+
if (middleSectionLength >= this.config.summarizationChunkSize && middleSectionLength >= MIN_MESSAGES_FOR_SUMMARIZATION_ATTEMPT) {
|
|
502
|
+
// The chunk ends where its last message's tool round ends. No round crosses the middle section's end, so the
|
|
503
|
+
// chunk stays inside the middle section.
|
|
504
|
+
const chunkEndIndex = rounds.end[middleSectionStartIndex + this.config.summarizationChunkSize - 1] + 1;
|
|
505
|
+
const messagesToSummarize = messages.slice(middleSectionStartIndex, chunkEndIndex);
|
|
506
|
+
// what the summary reads of each message, to tell whether one is rewritten while it is made
|
|
507
|
+
const summarizedContents = messagesToSummarize.map((m) => m.content);
|
|
307
508
|
const textToSummarize = messagesToSummarize
|
|
308
509
|
.map(m => `${m.name || m.role}: ${typeof m.content === 'string' ? m.content : (m.tool_calls ? '[Tool Call Invoked]' : '[Structured Content]')}`)
|
|
309
510
|
.join('\n\n');
|
|
310
511
|
const summaryContent = await this.utilityAI.summarize(textToSummarize, this.config.summarizationOptions);
|
|
512
|
+
// A history cleared while the summary was made no longer holds the messages it summarizes.
|
|
513
|
+
if (this.messages !== messages) {
|
|
514
|
+
console.log(`ConversationContext (ID: ${this.sessionId}): Summary of ${messagesToSummarize.length} messages dropped: the history was cleared while it was made.`);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
// A result recorded meanwhile for a call in the chunk, after other messages, ends the call's round past the
|
|
518
|
+
// chunk: the summary would leave the result without its call. It is dropped, and the pass the result
|
|
519
|
+
// started, which found this one making the summary, runs once the lock is released.
|
|
520
|
+
if (toolRoundBounds(messages).end[chunkEndIndex - 1] >= chunkEndIndex) {
|
|
521
|
+
console.log(`ConversationContext (ID: ${this.sessionId}): Summary of ${messagesToSummarize.length} messages dropped: a tool result recorded while it was made answers a call in its chunk.`);
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
// A message of the chunk rewritten meanwhile (an output guardrail rewrites a stored reply) is no longer what
|
|
525
|
+
// the summary read, and a summary of what it held could keep what the rewrite removed. The summary is
|
|
526
|
+
// dropped, and a pass of its own makes it again from the message as it is once the lock is released.
|
|
527
|
+
if (messagesToSummarize.some((m, index) => m.content !== summarizedContents[index])) {
|
|
528
|
+
console.log(`ConversationContext (ID: ${this.sessionId}): Summary of ${messagesToSummarize.length} messages dropped: a message of its chunk was rewritten while it was made, so it is made again.`);
|
|
529
|
+
this.deferredHistoryPasses += 1;
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
311
532
|
const summaryMessageOptions = {
|
|
312
533
|
// timestamp is removed from options, createConversationMessage will set it.
|
|
313
534
|
originalMessagesSummarizedCount: messagesToSummarize.length,
|
|
@@ -321,17 +542,16 @@ export class ConversationContext {
|
|
|
321
542
|
}, // Cast to MessageMetadata
|
|
322
543
|
};
|
|
323
544
|
const summaryMessage = createConversationMessage(MessageRole.SUMMARY, summaryContent, summaryMessageOptions);
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
this.messages = [...headMessages, summaryMessage, ...remainingMiddleAfterSummarizedChunk, ...tailMessages];
|
|
545
|
+
// The summary takes the chunk's place. While it was made the history could only grow, so the messages after
|
|
546
|
+
// the chunk, with any recorded meanwhile, stay as they are.
|
|
547
|
+
this.messages = [...messages.slice(0, middleSectionStartIndex), summaryMessage, ...messages.slice(chunkEndIndex)];
|
|
328
548
|
console.log(`ConversationContext (ID: ${this.sessionId}): History summarized. New length: ${this.messages.length}.`);
|
|
329
549
|
if (this.messages.length > this.config.maxHistoryLengthMessages) {
|
|
330
|
-
//
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
550
|
+
// The messages between the summary and the kept tail, the ones recorded meanwhile counted in. Too few for
|
|
551
|
+
// another chunk are trimmed, and the trim keeps this summary. Enough for one wait for the next pass: the
|
|
552
|
+
// one the next message starts, or one that found this pass making the summary.
|
|
553
|
+
const remainingMiddleLength = summaryMiddle(this.messages, headCount, tailCount).end - (middleSectionStartIndex + 1);
|
|
554
|
+
if (remainingMiddleLength < MIN_MESSAGES_FOR_SUMMARIZATION_ATTEMPT || remainingMiddleLength < this.config.summarizationChunkSize) {
|
|
335
555
|
this.truncateHistorySimple(this.config.maxHistoryLengthMessages);
|
|
336
556
|
}
|
|
337
557
|
}
|
|
@@ -346,6 +566,15 @@ export class ConversationContext {
|
|
|
346
566
|
}
|
|
347
567
|
finally {
|
|
348
568
|
this.isSummarizing = false;
|
|
569
|
+
// The passes that found this one making its summary run now, one after another, on the history as it is: the
|
|
570
|
+
// messages recorded meanwhile, after a clear too, get the passes they started. A message recorded between two
|
|
571
|
+
// of them can start a summary of its own, and each pass left would find it being made, count itself again
|
|
572
|
+
// and return at once, round after round on microtasks alone, so its reply could never arrive. They are left
|
|
573
|
+
// to the pass making that summary, which runs them once it is made.
|
|
574
|
+
while (this.deferredHistoryPasses > 0 && !this.isSummarizing) {
|
|
575
|
+
this.deferredHistoryPasses -= 1;
|
|
576
|
+
await this.manageHistoryLength();
|
|
577
|
+
}
|
|
349
578
|
}
|
|
350
579
|
}
|
|
351
580
|
else {
|
|
@@ -353,29 +582,74 @@ export class ConversationContext {
|
|
|
353
582
|
}
|
|
354
583
|
}
|
|
355
584
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
585
|
+
* Where a trim to `targetMessageCount` messages cuts `messages`: it keeps the first `messagesToKeepVerbatimHead` (at
|
|
586
|
+
* most `targetMessageCount`), the summary right after them and the last summary after them, and the newest that fill
|
|
587
|
+
* the rest. The head and the newest keep a tool round they reach into whole. A summary pass puts its summary right
|
|
588
|
+
* after the first messages, and each pass summarizes the one before it there. A conversation loaded from storage
|
|
589
|
+
* holds each stored summary where its own time sorts it, after the messages it replaced, and its last one stands for
|
|
590
|
+
* the ones stored before it; a pass on it starts a summary of its own right after the first messages, from messages
|
|
591
|
+
* the stored ones may not all stand for. So the two can stand for different messages the trim leaves out, and each
|
|
592
|
+
* that is not among the newest takes the place of the oldest of them, as long as one of those is still kept: the last
|
|
593
|
+
* summary alone when both do not fit. A summary is neither a call nor a result, so it is kept alone wherever it sits.
|
|
358
594
|
*
|
|
359
595
|
* @private
|
|
360
|
-
|
|
596
|
+
*/
|
|
597
|
+
trimCuts(messages, targetMessageCount) {
|
|
598
|
+
const headCount = Math.max(0, Math.min(this.config.messagesToKeepVerbatimHead, targetMessageCount));
|
|
599
|
+
const tailCount = Math.max(0, targetMessageCount - headCount);
|
|
600
|
+
if (headCount + tailCount >= messages.length) {
|
|
601
|
+
return { headEnd: messages.length, summaryIndexes: [], tailStart: messages.length };
|
|
602
|
+
}
|
|
603
|
+
const rounds = toolRoundBounds(messages);
|
|
604
|
+
const cuts = cutsKeepingToolRounds(messages, headCount, tailCount, rounds);
|
|
605
|
+
// the summary right after the head and the last summary after it
|
|
606
|
+
const summaries = [];
|
|
607
|
+
if (messages[cuts.headEnd]?.role === MessageRole.SUMMARY)
|
|
608
|
+
summaries.push(cuts.headEnd);
|
|
609
|
+
for (let index = messages.length - 1; index > cuts.headEnd; index -= 1) {
|
|
610
|
+
if (messages[index].role === MessageRole.SUMMARY) {
|
|
611
|
+
summaries.push(index);
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
// Both summaries when they fit, else the last one alone. Each summary before the newest keeps one fewer of them,
|
|
616
|
+
// while one of them is still kept. Neither cut moves before a summary: the head's end stays, and the newest start
|
|
617
|
+
// no earlier than before, so keeping fewer of them can only leave a summary before them.
|
|
618
|
+
for (const kept of [summaries, summaries.slice(-1)]) {
|
|
619
|
+
for (let reserved = 0; reserved <= kept.length && tailCount - reserved >= 1; reserved += 1) {
|
|
620
|
+
const next = reserved === 0 ? cuts : cutsKeepingToolRounds(messages, headCount, tailCount - reserved, rounds);
|
|
621
|
+
const before = kept.filter((index) => index < next.tailStart);
|
|
622
|
+
if (before.length <= reserved) {
|
|
623
|
+
return { headEnd: next.headEnd, summaryIndexes: before, tailStart: next.tailStart };
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return { ...cuts, summaryIndexes: [] };
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Performs simple truncation of message history from the middle: it keeps the first `messagesToKeepVerbatimHead`
|
|
631
|
+
* messages (at most `targetMessageCount`), the summary right after them and the last summary after them, and the
|
|
632
|
+
* newest that fill the rest of `targetMessageCount`. Each summary stands for messages the trim leaves out, so one
|
|
633
|
+
* that is not among the newest takes the place of the oldest of them, as long as one of those is still kept. A
|
|
634
|
+
* target of 0 keeps every message.
|
|
635
|
+
*
|
|
636
|
+
* Providers refuse a tool call without its result and a tool result without its call, so neither cut falls inside a
|
|
637
|
+
* tool round (an assistant message that names tool calls, the tool messages that answer them and anything between):
|
|
638
|
+
* a round the kept head or the kept newest messages reach into is kept whole. When keeping it whole passes
|
|
639
|
+
* `targetMessageCount`, the round is kept whole anyway and the history holds more messages, as the prompt engine's
|
|
640
|
+
* token trim (`PromptEngine.truncateMessages`) keeps a round it cannot drop. A round in the head stays; a round the
|
|
641
|
+
* newest messages reach into is left out whole by a later trim, once newer messages fill the rest.
|
|
642
|
+
*
|
|
643
|
+
* @private
|
|
644
|
+
* @param {number} targetMessageCount - The number of messages to keep, passed when a tool round stays whole.
|
|
361
645
|
*/
|
|
362
646
|
truncateHistorySimple(targetMessageCount) {
|
|
363
|
-
if (this.messages.length <= targetMessageCount) {
|
|
647
|
+
if (targetMessageCount <= 0 || this.messages.length <= targetMessageCount) {
|
|
364
648
|
return;
|
|
365
649
|
}
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
if (this.messages.length > headCount + tailMessagesToKeepCount) { // Check if truncation is actually needed
|
|
370
|
-
const headMessages = this.messages.slice(0, headCount);
|
|
371
|
-
const tailMessages = tailMessagesToKeepCount > 0 ? this.messages.slice(-tailMessagesToKeepCount) : [];
|
|
372
|
-
this.messages = [...headMessages, ...tailMessages];
|
|
373
|
-
}
|
|
374
|
-
// If targetMessageCount is very small, this might result in fewer messages than targetMessageCount if headCount itself exceeds it.
|
|
375
|
-
// Or if headCount + tailMessagesToKeepCount > this.messages.length (shouldn't happen if initial check passes).
|
|
376
|
-
// The logic prioritizes keeping head messages if targetCount is less than headCount.
|
|
377
|
-
if (this.messages.length > targetMessageCount) { // Final trim if somehow still over
|
|
378
|
-
this.messages.splice(targetMessageCount);
|
|
650
|
+
const cuts = this.trimCuts(this.messages, targetMessageCount);
|
|
651
|
+
if (cuts.headEnd < cuts.tailStart) {
|
|
652
|
+
this.messages = keptByTrim(this.messages, cuts);
|
|
379
653
|
}
|
|
380
654
|
console.log(`ConversationContext (ID: ${this.sessionId}): History truncated simply. New length: ${this.messages.length}. Target: ${targetMessageCount}.`);
|
|
381
655
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationContext.js","sourceRoot":"","sources":["../../../src/core/conversation/ConversationContext.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE;;;;;;;;;GASG;AAEH,OAAO,EAAuB,WAAW,EAAE,yBAAyB,EAAmB,MAAM,uBAAuB,CAAC;AAErH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC,CAAC,iBAAiB;AAE9E,oCAAoC;AACpC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AACtC,MAAM,gCAAgC,GAAG,EAAE,CAAC,CAAC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AAQ,CAAC,eAAe,IAAI,EAAE,CAC/B,CAAC;QAEF,6DAA6D;QAC7D,IAAI,OAAO,QAAQ,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC3C,wEAAwE;YACxE,2FAA2F;YAC1F,OAAoE,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;QACvG,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,IAAW,MAAM,KAAyB,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAErG;;;;OAIG;IACH,IAAW,aAAa,KAAyB,OAAO,IAAI,CAAC,eAAe,CAAC,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAE1H;;;;OAIG;IACH,IAAW,eAAe,KAAyB,OAAO,IAAI,CAAC,eAAe,CAAC,eAAe,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;IAEhI;;;;OAIG;IACH,IAAW,eAAe,KAAa,OAAO,IAAI,CAAC,eAAe,CAAC,eAAe,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;CACrH"}
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* @see ../../ai_utilities/IUtilityAI.ts
|
|
10
10
|
* @see @framers/sql-storage-adapter
|
|
11
11
|
*/
|
|
12
|
-
import { ConversationContext, ConversationContextConfig } from './ConversationContext';
|
|
13
|
-
import { IUtilityAI } from '../../cognition/nlp/ai_utilities/IUtilityAI';
|
|
12
|
+
import { ConversationContext, ConversationContextConfig } from './ConversationContext.js';
|
|
13
|
+
import { IUtilityAI } from '../../cognition/nlp/ai_utilities/IUtilityAI.js';
|
|
14
14
|
import type { StorageAdapter } from '@framers/sql-storage-adapter';
|
|
15
15
|
/**
|
|
16
16
|
* Configuration for the ConversationManager.
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* @see ../../cognitive_substrate/IGMI.ts for ToolCallRequest definition.
|
|
10
10
|
* @see ../ai_utilities/IUtilityAI.ts for SentimentResult.
|
|
11
11
|
*/
|
|
12
|
-
import { ToolCallRequest as GMIToolCallRequest } from '../../cognition/substrate/IGMI';
|
|
13
|
-
import { SentimentResult } from '../../cognition/nlp/ai_utilities/IUtilityAI';
|
|
14
|
-
import type { ThinkingBlock } from '../llm/providers/IProvider';
|
|
12
|
+
import { ToolCallRequest as GMIToolCallRequest } from '../../cognition/substrate/IGMI.js';
|
|
13
|
+
import { SentimentResult } from '../../cognition/nlp/ai_utilities/IUtilityAI.js';
|
|
14
|
+
import type { ThinkingBlock } from '../llm/providers/IProvider.js';
|
|
15
15
|
/**
|
|
16
16
|
* Represents the role of the entity that produced the message.
|
|
17
17
|
* Critical for LLM interpretation and system logic.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResolvedLongTermMemoryPolicy } from './LongTermMemoryPolicy';
|
|
1
|
+
import type { ResolvedLongTermMemoryPolicy } from './LongTermMemoryPolicy.js';
|
|
2
2
|
import type { MemoryRetrievalPolicy } from '../../cognition/rag/unified/policy.js';
|
|
3
3
|
export interface LongTermMemoryRetrievalInput {
|
|
4
4
|
userId: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* AgentOS keeps the rolling summary inside the per-conversation `ConversationContext` metadata for
|
|
6
6
|
* prompt compaction. This sink is for *cross-conversation* retrieval and analytics.
|
|
7
7
|
*/
|
|
8
|
-
import type { ResolvedLongTermMemoryPolicy } from './LongTermMemoryPolicy';
|
|
8
|
+
import type { ResolvedLongTermMemoryPolicy } from './LongTermMemoryPolicy.js';
|
|
9
9
|
export interface RollingSummaryMemoryUpdate {
|
|
10
10
|
userId: string;
|
|
11
11
|
/** Optional organization context (multi-tenant / org-scoped memory). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChatMessage, ModelCompletionOptions } from '../llm/providers/IProvider';
|
|
2
|
-
import type { ConversationMessage } from './ConversationMessage';
|
|
1
|
+
import type { ChatMessage, ModelCompletionOptions } from '../llm/providers/IProvider.js';
|
|
2
|
+
import type { ConversationMessage } from './ConversationMessage.js';
|
|
3
3
|
export interface RollingSummaryCompactionConfig {
|
|
4
4
|
enabled: boolean;
|
|
5
5
|
/**
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @see ../llm/providers/AIModelProviderManager.ts
|
|
16
16
|
* @see ../../rag/EmbeddingManager.ts for a concrete implementation.
|
|
17
17
|
*/
|
|
18
|
-
import { AIModelProviderManager } from '../llm/providers/AIModelProviderManager';
|
|
18
|
+
import { AIModelProviderManager } from '../llm/providers/AIModelProviderManager.js';
|
|
19
19
|
import { EmbeddingManagerConfig, EmbeddingModelConfig } from '../config/EmbeddingManagerConfiguration.js';
|
|
20
20
|
/**
|
|
21
21
|
* Represents a request to generate embeddings.
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* See `docs/PROMPTS.MD` for detailed architectural documentation.
|
|
22
22
|
* @see {@link IPersonaDefinition} for persona-driven prompting.
|
|
23
23
|
*/
|
|
24
|
-
import { IPersonaDefinition, ContextualPromptElement, ContextualPromptElementCriteria } from '../../cognition/substrate/personas/IPersonaDefinition';
|
|
25
|
-
import { IWorkingMemory } from '../../cognition/substrate/memory/IWorkingMemory';
|
|
26
|
-
import { ITool } from '../tools/ITool';
|
|
27
|
-
import { VisionInputData, AudioInputData } from '../../cognition/substrate/IGMI';
|
|
28
|
-
import { ConversationMessage as Message } from '../conversation/ConversationMessage';
|
|
29
|
-
import { ChatMessage } from './providers/IProvider';
|
|
24
|
+
import { IPersonaDefinition, ContextualPromptElement, ContextualPromptElementCriteria } from '../../cognition/substrate/personas/IPersonaDefinition.js';
|
|
25
|
+
import { IWorkingMemory } from '../../cognition/substrate/memory/IWorkingMemory.js';
|
|
26
|
+
import { ITool } from '../tools/ITool.js';
|
|
27
|
+
import { VisionInputData, AudioInputData } from '../../cognition/substrate/IGMI.js';
|
|
28
|
+
import { ConversationMessage as Message } from '../conversation/ConversationMessage.js';
|
|
29
|
+
import { ChatMessage } from './providers/IProvider.js';
|
|
30
30
|
/**
|
|
31
31
|
* Represents different types of contextual prompt elements that can be dynamically
|
|
32
32
|
* selected and integrated into prompts based on execution context.
|