@roj-ai/sdk 0.1.14 → 0.1.16
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/bootstrap.d.ts +1 -0
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/core/agents/agent.d.ts +25 -1
- package/dist/core/agents/agent.d.ts.map +1 -1
- package/dist/core/agents/agent.js +117 -21
- package/dist/core/agents/agent.js.map +1 -1
- package/dist/core/agents/config.d.ts +7 -0
- package/dist/core/agents/config.d.ts.map +1 -1
- package/dist/core/agents/context.d.ts +10 -0
- package/dist/core/agents/context.d.ts.map +1 -1
- package/dist/core/agents/state.d.ts +11 -3
- package/dist/core/agents/state.d.ts.map +1 -1
- package/dist/core/agents/state.js.map +1 -1
- package/dist/core/file-store/file-store.d.ts +5 -1
- package/dist/core/file-store/file-store.d.ts.map +1 -1
- package/dist/core/file-store/file-store.js +31 -21
- package/dist/core/file-store/file-store.js.map +1 -1
- package/dist/core/image/vips-resizer.test.js +26 -14
- package/dist/core/image/vips-resizer.test.js.map +1 -1
- package/dist/core/llm/anthropic.d.ts.map +1 -1
- package/dist/core/llm/anthropic.js +11 -8
- package/dist/core/llm/anthropic.js.map +1 -1
- package/dist/core/llm/cache-breakpoints.d.ts +5 -1
- package/dist/core/llm/cache-breakpoints.d.ts.map +1 -1
- package/dist/core/llm/cache-breakpoints.js +10 -5
- package/dist/core/llm/cache-breakpoints.js.map +1 -1
- package/dist/core/sessions/session.d.ts.map +1 -1
- package/dist/core/sessions/session.js +3 -0
- package/dist/core/sessions/session.js.map +1 -1
- package/dist/core/sessions/session.test.js +5 -0
- package/dist/core/sessions/session.test.js.map +1 -1
- package/dist/core/sessions/state.d.ts.map +1 -1
- package/dist/core/sessions/state.js +5 -1
- package/dist/core/sessions/state.js.map +1 -1
- package/dist/core/tools/executor.test.js +1 -0
- package/dist/core/tools/executor.test.js.map +1 -1
- package/dist/plugins/agent-status/plugin.d.ts.map +1 -1
- package/dist/plugins/agent-status/plugin.js +18 -26
- package/dist/plugins/agent-status/plugin.js.map +1 -1
- package/dist/plugins/context-compact/compaction-live.test.d.ts +17 -0
- package/dist/plugins/context-compact/compaction-live.test.d.ts.map +1 -0
- package/dist/plugins/context-compact/compaction-live.test.js +177 -0
- package/dist/plugins/context-compact/compaction-live.test.js.map +1 -0
- package/dist/plugins/context-compact/context-compact.integration.test.js +123 -3
- package/dist/plugins/context-compact/context-compact.integration.test.js.map +1 -1
- package/dist/plugins/context-compact/context-compactor.d.ts +47 -17
- package/dist/plugins/context-compact/context-compactor.d.ts.map +1 -1
- package/dist/plugins/context-compact/context-compactor.js +60 -36
- package/dist/plugins/context-compact/context-compactor.js.map +1 -1
- package/dist/plugins/context-compact/context-compactor.test.js +69 -103
- package/dist/plugins/context-compact/context-compactor.test.js.map +1 -1
- package/dist/plugins/context-compact/plugin.d.ts +9 -2
- package/dist/plugins/context-compact/plugin.d.ts.map +1 -1
- package/dist/plugins/context-compact/plugin.js +8 -4
- package/dist/plugins/context-compact/plugin.js.map +1 -1
- package/dist/plugins/filesystem/filesystem.integration.test.js +36 -0
- package/dist/plugins/filesystem/filesystem.integration.test.js.map +1 -1
- package/dist/plugins/filesystem/plugin.d.ts.map +1 -1
- package/dist/plugins/filesystem/plugin.js +8 -6
- package/dist/plugins/filesystem/plugin.js.map +1 -1
- package/dist/plugins/mailbox/mailbox.integration.test.js +9 -16
- package/dist/plugins/mailbox/mailbox.integration.test.js.map +1 -1
- package/dist/plugins/resources/plugin.d.ts.map +1 -1
- package/dist/plugins/resources/plugin.js +4 -1
- package/dist/plugins/resources/plugin.js.map +1 -1
- package/dist/plugins/uploads/preprocessors/image-classifier.d.ts.map +1 -1
- package/dist/plugins/uploads/preprocessors/image-classifier.js +15 -2
- package/dist/plugins/uploads/preprocessors/image-classifier.js.map +1 -1
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.d.ts.map +1 -1
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.js +72 -19
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.js.map +1 -1
- package/dist/plugins/user-chat/plugin.d.ts +2 -0
- package/dist/plugins/user-chat/plugin.d.ts.map +1 -1
- package/dist/plugins/user-chat/plugin.js +47 -3
- package/dist/plugins/user-chat/plugin.js.map +1 -1
- package/dist/plugins/user-chat/schema.d.ts +10 -0
- package/dist/plugins/user-chat/schema.d.ts.map +1 -1
- package/dist/plugins/user-chat/schema.js +1 -0
- package/dist/plugins/user-chat/schema.js.map +1 -1
- package/dist/plugins/user-chat/user-chat.integration.test.js +86 -0
- package/dist/plugins/user-chat/user-chat.integration.test.js.map +1 -1
- package/package.json +2 -2
- package/src/core/agents/agent.ts +134 -20
- package/src/core/agents/config.ts +7 -0
- package/src/core/agents/context.ts +11 -0
- package/src/core/agents/state.ts +11 -4
- package/src/core/file-store/file-store.ts +38 -18
- package/src/core/image/vips-resizer.test.ts +26 -15
- package/src/core/llm/anthropic.ts +19 -12
- package/src/core/llm/cache-breakpoints.ts +15 -6
- package/src/core/sessions/session.test.ts +6 -0
- package/src/core/sessions/session.ts +4 -0
- package/src/core/sessions/state.ts +5 -1
- package/src/core/tools/executor.test.ts +1 -0
- package/src/plugins/agent-status/plugin.ts +18 -25
- package/src/plugins/context-compact/compaction-live.test.ts +221 -0
- package/src/plugins/context-compact/context-compact.integration.test.ts +135 -3
- package/src/plugins/context-compact/context-compactor.test.ts +71 -110
- package/src/plugins/context-compact/context-compactor.ts +88 -43
- package/src/plugins/context-compact/plugin.ts +19 -10
- package/src/plugins/filesystem/filesystem.integration.test.ts +44 -0
- package/src/plugins/filesystem/plugin.ts +8 -6
- package/src/plugins/mailbox/mailbox.integration.test.ts +12 -18
- package/src/plugins/resources/plugin.ts +4 -1
- package/src/plugins/uploads/preprocessors/image-classifier.ts +15 -2
- package/src/plugins/uploads/preprocessors/markitdown-preprocessor.ts +89 -20
- package/src/plugins/user-chat/plugin.ts +60 -3
- package/src/plugins/user-chat/schema.ts +10 -1
- package/src/plugins/user-chat/user-chat.integration.test.ts +99 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live compaction tests against the real Anthropic API.
|
|
3
|
+
*
|
|
4
|
+
* Opt-in: run with `LIVE_TESTS=1 ANTHROPIC_API_KEY=…`. Skipped otherwise so the
|
|
5
|
+
* default `bun test` run stays hermetic.
|
|
6
|
+
*
|
|
7
|
+
* These cover the two real-API claims of the context-compact rewrite (5c27ab7):
|
|
8
|
+
* 1. The auxiliary-inference call (used by `ContextCompactor`) reuses the
|
|
9
|
+
* agent's warm prompt cache — only the trailing instruction + output are
|
|
10
|
+
* paid for, not the whole conversation a second time.
|
|
11
|
+
* 2. `DEFAULT_SUMMARY_INSTRUCTION` actually elicits a plain-text summary from
|
|
12
|
+
* a real Sonnet/Haiku-class model (no tool calls, non-empty content), so
|
|
13
|
+
* the end-to-end `ContextCompactor.compact()` path produces a usable
|
|
14
|
+
* `[CONVERSATION SUMMARY]` block.
|
|
15
|
+
*/
|
|
16
|
+
import { describe, expect, test } from 'bun:test';
|
|
17
|
+
import { generateTestAgentId } from '../../core/agents/schema.js';
|
|
18
|
+
import { AnthropicProvider } from '../../core/llm/anthropic.js';
|
|
19
|
+
import { applyCacheBreakpoint } from '../../core/llm/cache-breakpoints.js';
|
|
20
|
+
import { ModelId } from '../../core/llm/schema.js';
|
|
21
|
+
import { generateSessionId } from '../../core/sessions/schema.js';
|
|
22
|
+
import { silentLogger } from '../../lib/logger/logger.js';
|
|
23
|
+
import { ContextCompactor, DEFAULT_SUMMARY_INSTRUCTION, } from './context-compactor.js';
|
|
24
|
+
const liveEnabled = process.env.LIVE_TESTS === '1';
|
|
25
|
+
const anthropicApiKey = liveEnabled ? process.env.ANTHROPIC_API_KEY : undefined;
|
|
26
|
+
const describeLive = (name, apiKey, fn) => {
|
|
27
|
+
if (!apiKey) {
|
|
28
|
+
describe.skip(`${name} (skipped — API key missing)`, fn);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
describe(name, fn);
|
|
32
|
+
};
|
|
33
|
+
const noopImageProcessor = {
|
|
34
|
+
resolveContent: async (content) => content,
|
|
35
|
+
};
|
|
36
|
+
const MODEL = ModelId('claude-haiku-4-5-20251001');
|
|
37
|
+
/**
|
|
38
|
+
* Padded system prompt so the cacheable prefix comfortably exceeds Anthropic's
|
|
39
|
+
* 1024-token minimum for Haiku. Deterministic content so identical calls reuse
|
|
40
|
+
* the exact same prefix.
|
|
41
|
+
*/
|
|
42
|
+
const LARGE_SYSTEM_PROMPT = [
|
|
43
|
+
'You are a meticulous assistant helping a developer review a long conversation.',
|
|
44
|
+
'Always respond concisely and accurately. Never speculate beyond the data.',
|
|
45
|
+
'Follow these rules strictly:',
|
|
46
|
+
...Array.from({ length: 120 }, (_, i) => `- Rule ${i + 1}: When asked about topic ${i + 1}, prefer factual sources and decline to speculate.`),
|
|
47
|
+
'End of instructions.',
|
|
48
|
+
].join('\n');
|
|
49
|
+
/**
|
|
50
|
+
* Deterministic multi-turn history padded well past 1024 tokens so cache writes
|
|
51
|
+
* and reads are unambiguous. Includes both user and assistant messages, which
|
|
52
|
+
* is the shape an inline-compaction call sees in practice.
|
|
53
|
+
*/
|
|
54
|
+
function buildLongHistory() {
|
|
55
|
+
const history = [];
|
|
56
|
+
for (let i = 0; i < 8; i++) {
|
|
57
|
+
history.push({
|
|
58
|
+
role: 'user',
|
|
59
|
+
content: `Turn ${i + 1} user: please analyze topic ${i + 1}. `
|
|
60
|
+
+ 'context detail '.repeat(30),
|
|
61
|
+
});
|
|
62
|
+
history.push({
|
|
63
|
+
role: 'assistant',
|
|
64
|
+
content: `Turn ${i + 1} assistant: here is my analysis of topic ${i + 1}. `
|
|
65
|
+
+ 'analysis detail '.repeat(30),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return history;
|
|
69
|
+
}
|
|
70
|
+
describeLive('context-compact live: auxiliary inference cache reuse', anthropicApiKey, () => {
|
|
71
|
+
test('priming inference then auxiliary summary call hits the prompt cache', async () => {
|
|
72
|
+
const provider = new AnthropicProvider({
|
|
73
|
+
apiKey: anthropicApiKey,
|
|
74
|
+
imageProcessor: noopImageProcessor,
|
|
75
|
+
defaultModel: 'claude-haiku-4-5-20251001',
|
|
76
|
+
});
|
|
77
|
+
const history = buildLongHistory();
|
|
78
|
+
// Call 1: regular inference, breakpoint on the last history message.
|
|
79
|
+
// Mirrors what an Agent.advance() turn does just before requesting a
|
|
80
|
+
// compaction summary.
|
|
81
|
+
const primeMessages = applyCacheBreakpoint(history, 0, '1h');
|
|
82
|
+
const prime = await provider.inference({
|
|
83
|
+
model: MODEL,
|
|
84
|
+
systemPrompt: LARGE_SYSTEM_PROMPT,
|
|
85
|
+
messages: primeMessages,
|
|
86
|
+
});
|
|
87
|
+
if (!prime.ok) {
|
|
88
|
+
if (prime.error.message?.includes('credit balance')) {
|
|
89
|
+
console.warn('⚠️ Live compaction cache test skipped: credit balance too low');
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`prime call failed: ${JSON.stringify(prime.error)}`);
|
|
93
|
+
}
|
|
94
|
+
expect(prime.value.metrics.promptTokens).toBeGreaterThan(1024);
|
|
95
|
+
// Call 2: simulate Agent.runAuxiliaryInference — append the summary
|
|
96
|
+
// instruction as a trailing user message and place the breakpoint at
|
|
97
|
+
// the same position as the prime call (last history message), so the
|
|
98
|
+
// whole prefix lands as a cache read.
|
|
99
|
+
const summaryInstruction = { role: 'user', content: DEFAULT_SUMMARY_INSTRUCTION };
|
|
100
|
+
const auxMessages = applyCacheBreakpoint([...history, summaryInstruction], 1, '1h');
|
|
101
|
+
const aux = await provider.inference({
|
|
102
|
+
model: MODEL,
|
|
103
|
+
systemPrompt: LARGE_SYSTEM_PROMPT,
|
|
104
|
+
messages: auxMessages,
|
|
105
|
+
});
|
|
106
|
+
if (!aux.ok)
|
|
107
|
+
throw new Error(`auxiliary call failed: ${JSON.stringify(aux.error)}`);
|
|
108
|
+
// Core claim: the auxiliary call served the prefix from cache (otherwise
|
|
109
|
+
// we'd re-upload the entire conversation just to get a summary).
|
|
110
|
+
expect(aux.value.metrics.cachedTokens ?? 0).toBeGreaterThan(1024);
|
|
111
|
+
// Sonnet/Haiku reliably emit plain text under DEFAULT_SUMMARY_INSTRUCTION.
|
|
112
|
+
// If this regresses, the prompt is no longer fit for purpose.
|
|
113
|
+
expect(aux.value.toolCalls).toHaveLength(0);
|
|
114
|
+
expect(aux.value.finishReason).toBe('stop');
|
|
115
|
+
expect(aux.value.content ?? '').not.toBe('');
|
|
116
|
+
}, 60_000);
|
|
117
|
+
});
|
|
118
|
+
describeLive('context-compact live: end-to-end compactor', anthropicApiKey, () => {
|
|
119
|
+
test('ContextCompactor.compact() produces a real summary from a real model', async () => {
|
|
120
|
+
const provider = new AnthropicProvider({
|
|
121
|
+
apiKey: anthropicApiKey,
|
|
122
|
+
imageProcessor: noopImageProcessor,
|
|
123
|
+
defaultModel: 'claude-haiku-4-5-20251001',
|
|
124
|
+
});
|
|
125
|
+
const history = buildLongHistory();
|
|
126
|
+
// Wraps the provider exactly the way AgentContext.runAuxiliaryInference
|
|
127
|
+
// does: full prefix + extraMessages, breakpoint pinned to the last
|
|
128
|
+
// pre-extraMessages position so the agent's cache is reused.
|
|
129
|
+
const auxCalls = [];
|
|
130
|
+
const runInference = async (extraMessages) => {
|
|
131
|
+
const messages = applyCacheBreakpoint([...history, ...extraMessages], extraMessages.length, '1h');
|
|
132
|
+
const result = await provider.inference({
|
|
133
|
+
model: MODEL,
|
|
134
|
+
systemPrompt: LARGE_SYSTEM_PROMPT,
|
|
135
|
+
messages,
|
|
136
|
+
});
|
|
137
|
+
if (result.ok)
|
|
138
|
+
auxCalls.push(result.value);
|
|
139
|
+
return result;
|
|
140
|
+
};
|
|
141
|
+
// Prime the cache with one regular inference first, otherwise the
|
|
142
|
+
// auxiliary call would pay full write cost — same as a real session
|
|
143
|
+
// where compaction always runs after at least one normal turn.
|
|
144
|
+
const prime = await provider.inference({
|
|
145
|
+
model: MODEL,
|
|
146
|
+
systemPrompt: LARGE_SYSTEM_PROMPT,
|
|
147
|
+
messages: applyCacheBreakpoint(history, 0, '1h'),
|
|
148
|
+
});
|
|
149
|
+
if (!prime.ok) {
|
|
150
|
+
if (prime.error.message?.includes('credit balance')) {
|
|
151
|
+
console.warn('⚠️ Live compaction end-to-end test skipped: credit balance too low');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
throw new Error(`prime call failed: ${JSON.stringify(prime.error)}`);
|
|
155
|
+
}
|
|
156
|
+
const compactor = new ContextCompactor(silentLogger, {
|
|
157
|
+
// Force compaction regardless of estimator vs actual tokens.
|
|
158
|
+
maxTokens: 10,
|
|
159
|
+
keepRecentMessages: 2,
|
|
160
|
+
});
|
|
161
|
+
const result = await compactor.compact(generateSessionId(), generateTestAgentId(), history, runInference);
|
|
162
|
+
expect(result.ok).toBe(true);
|
|
163
|
+
if (!result.ok)
|
|
164
|
+
return;
|
|
165
|
+
expect(result.value.messagesRemoved).toBeGreaterThan(0);
|
|
166
|
+
expect(result.value.summary.trim().length).toBeGreaterThan(0);
|
|
167
|
+
// keepRecentMessages=2 → summary message + 2 kept = 3 total
|
|
168
|
+
expect(result.value.compactedMessages).toHaveLength(3);
|
|
169
|
+
expect(result.value.compactedMessages[0].role).toBe('user');
|
|
170
|
+
expect(result.value.compactedMessages[0].content).toContain('[CONVERSATION SUMMARY]');
|
|
171
|
+
// The auxiliary inference under the compactor should have served the
|
|
172
|
+
// prefix from cache (priming call wrote it).
|
|
173
|
+
expect(auxCalls).toHaveLength(1);
|
|
174
|
+
expect(auxCalls[0].metrics.cachedTokens ?? 0).toBeGreaterThan(1024);
|
|
175
|
+
}, 60_000);
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=compaction-live.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-live.test.js","sourceRoot":"","sources":["../../../src/plugins/context-compact/compaction-live.test.ts"],"names":[],"mappings":"AAAA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AAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QACtD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC3D,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAiB,CAAC,CAAC,SAAS,CACpE,wBAAwB,CACxB,CAAA;QAED,qEAAqE;QACrE,6CAA6C;QAC7C,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QAChC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;IACpE,CAAC,EAAE,MAAM,CAAC,CAAA;AACX,CAAC,CAAC,CAAA"}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import z from 'zod/v4';
|
|
2
3
|
import { contextEvents } from '../../core/context/state.js';
|
|
3
4
|
import { MockLLMProvider } from '../../core/llm/mock.js';
|
|
4
5
|
import { ModelId } from '../../core/llm/schema.js';
|
|
6
|
+
import { createTool } from '../../core/tools/definition.js';
|
|
7
|
+
import { ToolCallId } from '../../core/tools/schema.js';
|
|
5
8
|
import { createTestPreset, TestHarness } from '../../testing/index.js';
|
|
6
9
|
import { contextCompactPlugin } from './index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Inline compaction sends the agent's regular systemPrompt and full conversation
|
|
12
|
+
* to the LLM, with a trailing user message containing the summarization
|
|
13
|
+
* instruction. We detect compaction calls by looking at that trailing message.
|
|
14
|
+
*/
|
|
15
|
+
function isSummarizationRequest(request) {
|
|
16
|
+
const last = request.messages[request.messages.length - 1];
|
|
17
|
+
if (!last || last.role !== 'user')
|
|
18
|
+
return false;
|
|
19
|
+
const content = typeof last.content === 'string' ? last.content : JSON.stringify(last.content);
|
|
20
|
+
return content.includes('[CONTEXT COMPACTION REQUEST]');
|
|
21
|
+
}
|
|
7
22
|
// ============================================================================
|
|
8
23
|
// Helpers
|
|
9
24
|
// ============================================================================
|
|
@@ -44,7 +59,7 @@ describe('context-compact plugin', () => {
|
|
|
44
59
|
presets: [createCompactPreset(10)],
|
|
45
60
|
mockHandler: (request) => {
|
|
46
61
|
// Compaction requests use CONTEXT_SUMMARY_PROMPT which contains "summarizer".
|
|
47
|
-
if (
|
|
62
|
+
if (isSummarizationRequest(request)) {
|
|
48
63
|
return {
|
|
49
64
|
content: 'Summary of conversation so far.',
|
|
50
65
|
toolCalls: [],
|
|
@@ -100,7 +115,7 @@ describe('context-compact plugin', () => {
|
|
|
100
115
|
mockHandler: (request) => {
|
|
101
116
|
inferenceCallCount++;
|
|
102
117
|
// Summarization requests (from context-compact plugin)
|
|
103
|
-
if (
|
|
118
|
+
if (isSummarizationRequest(request)) {
|
|
104
119
|
return {
|
|
105
120
|
content: 'Conversation summary.',
|
|
106
121
|
toolCalls: [],
|
|
@@ -132,6 +147,111 @@ describe('context-compact plugin', () => {
|
|
|
132
147
|
});
|
|
133
148
|
});
|
|
134
149
|
// =========================================================================
|
|
150
|
+
// Pending tool results regression
|
|
151
|
+
// =========================================================================
|
|
152
|
+
describe('pending tool results', () => {
|
|
153
|
+
it('aux inference after a tool turn includes the tool_result before the summary instruction', async () => {
|
|
154
|
+
// Regression for the bug where context-compact's auxiliary inference call
|
|
155
|
+
// runs at a moment where `conversationHistory` ends with an assistant
|
|
156
|
+
// `tool_use` block but the corresponding tool_result is still in
|
|
157
|
+
// `pendingToolResults` (not yet committed to history). Sending
|
|
158
|
+
// `[..., assistant(tool_use), user(summary)]` to Anthropic 400s with
|
|
159
|
+
// "tool_use blocks must be followed by tool_result blocks".
|
|
160
|
+
const myTool = createTool({
|
|
161
|
+
name: 'my_tool',
|
|
162
|
+
description: 'returns a fixed value',
|
|
163
|
+
input: z.object({}),
|
|
164
|
+
execute: async () => ({ ok: true, value: 'tool result content' }),
|
|
165
|
+
});
|
|
166
|
+
const preset = {
|
|
167
|
+
id: 'test',
|
|
168
|
+
name: 'Tool Compaction Test',
|
|
169
|
+
orchestrator: {
|
|
170
|
+
system: 'You are a test agent.',
|
|
171
|
+
model: ModelId('mock'),
|
|
172
|
+
tools: [myTool],
|
|
173
|
+
agents: [],
|
|
174
|
+
debounceMs: 0,
|
|
175
|
+
},
|
|
176
|
+
agents: [],
|
|
177
|
+
plugins: [
|
|
178
|
+
contextCompactPlugin.configure({
|
|
179
|
+
compaction: {
|
|
180
|
+
model: ModelId('mock'),
|
|
181
|
+
maxTokens: 10,
|
|
182
|
+
// 1 so that after the tool turn, [user, assistant(tool_use)]
|
|
183
|
+
// splits into toCompact=[user], toKeep=[assistant(tool_use)] —
|
|
184
|
+
// the aux call actually runs and gets the buggy prefix.
|
|
185
|
+
keepRecentMessages: 1,
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
],
|
|
189
|
+
};
|
|
190
|
+
let capturedAuxRequest;
|
|
191
|
+
const harness = new TestHarness({
|
|
192
|
+
systemPlugins: [contextCompactPlugin],
|
|
193
|
+
presets: [preset],
|
|
194
|
+
mockHandler: (request) => {
|
|
195
|
+
if (isSummarizationRequest(request)) {
|
|
196
|
+
capturedAuxRequest = request;
|
|
197
|
+
return {
|
|
198
|
+
content: 'Summary of conversation.',
|
|
199
|
+
toolCalls: [],
|
|
200
|
+
finishReason: 'stop',
|
|
201
|
+
metrics: MockLLMProvider.defaultMetrics(),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// First inference (no tool messages in history yet) → emit a tool call.
|
|
205
|
+
const hasToolMessages = request.messages.some((m) => m.role === 'tool');
|
|
206
|
+
if (!hasToolMessages) {
|
|
207
|
+
return {
|
|
208
|
+
content: '',
|
|
209
|
+
toolCalls: [{ id: ToolCallId('tc1'), name: 'my_tool', input: {} }],
|
|
210
|
+
finishReason: 'tool_calls',
|
|
211
|
+
metrics: MockLLMProvider.defaultMetrics(),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
content: 'Done.',
|
|
216
|
+
toolCalls: [],
|
|
217
|
+
finishReason: 'stop',
|
|
218
|
+
metrics: MockLLMProvider.defaultMetrics(),
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
const session = await harness.createSession('test');
|
|
223
|
+
await session.sendAndWaitForIdle('Please call my_tool');
|
|
224
|
+
expect(capturedAuxRequest).toBeDefined();
|
|
225
|
+
// Every assistant message with toolCalls must be followed by a contiguous
|
|
226
|
+
// run of tool messages covering each tool_use id before any further
|
|
227
|
+
// user/assistant message. This mirrors Anthropic's API contract.
|
|
228
|
+
const msgs = capturedAuxRequest.messages;
|
|
229
|
+
for (let i = 0; i < msgs.length; i++) {
|
|
230
|
+
const m = msgs[i];
|
|
231
|
+
if (m.role !== 'assistant' || !m.toolCalls?.length)
|
|
232
|
+
continue;
|
|
233
|
+
const expected = new Set(m.toolCalls.map((tc) => tc.id));
|
|
234
|
+
const seen = new Set();
|
|
235
|
+
for (let j = i + 1; j < msgs.length; j++) {
|
|
236
|
+
const next = msgs[j];
|
|
237
|
+
if (next.role !== 'tool')
|
|
238
|
+
break;
|
|
239
|
+
seen.add(next.toolCallId);
|
|
240
|
+
}
|
|
241
|
+
for (const id of expected) {
|
|
242
|
+
expect(seen.has(id)).toBe(true);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// Compaction must have actually succeeded — pre-fix it would Err-out
|
|
246
|
+
// in production (mock accepts it but the assertion above already
|
|
247
|
+
// catches the malformed-prefix case).
|
|
248
|
+
const compactedEvents = await session.getEventsByType(contextEvents, 'context_compacted');
|
|
249
|
+
const actualCompactions = compactedEvents.filter((e) => e.messagesRemoved > 0);
|
|
250
|
+
expect(actualCompactions.length).toBeGreaterThanOrEqual(1);
|
|
251
|
+
await harness.shutdown();
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
// =========================================================================
|
|
135
255
|
// Compaction failure
|
|
136
256
|
// =========================================================================
|
|
137
257
|
describe('compaction failure', () => {
|
|
@@ -142,7 +262,7 @@ describe('context-compact plugin', () => {
|
|
|
142
262
|
mockHandler: (request) => {
|
|
143
263
|
// Summarization requests — throw to simulate LLM failure.
|
|
144
264
|
// MockLLMProvider only returns Err() when the handler throws.
|
|
145
|
-
if (
|
|
265
|
+
if (isSummarizationRequest(request)) {
|
|
146
266
|
throw { type: 'server_error', message: 'LLM summarization failed' };
|
|
147
267
|
}
|
|
148
268
|
// Regular inference
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-compact.integration.test.js","sourceRoot":"","sources":["../../../src/plugins/context-compact/context-compact.integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"context-compact.integration.test.js","sourceRoot":"","sources":["../../../src/plugins/context-compact/context-compact.integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,CAAC,MAAM,QAAQ,CAAA;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,EAAE,oBAAoB,EA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AA;YAEzC,mEAAmE;YACnE,MAAM,CAAC,gBAAgB,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;YAElD,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;QACzB,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,33 +1,53 @@
|
|
|
1
1
|
import type { AgentId } from '../../core/agents/schema.js';
|
|
2
2
|
import type { ContextCompactedEvent } from '../../core/context/state.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { InferenceResponse, LLMError, LLMMessage } from '../../core/llm/provider.js';
|
|
4
4
|
import type { ModelId } from '../../core/llm/schema.js';
|
|
5
5
|
import type { SessionId } from '../../core/sessions/schema.js';
|
|
6
6
|
import type { Result } from '../../lib/utils/result.js';
|
|
7
7
|
import type { Logger } from '../../lib/logger/logger.js';
|
|
8
|
+
/**
|
|
9
|
+
* Callback used by the compactor to ask the host (an Agent) to run a side-channel
|
|
10
|
+
* inference reusing its own system prompt, tools, and conversation prefix.
|
|
11
|
+
*
|
|
12
|
+
* Implemented in practice by AgentContext.runAuxiliaryInference, which keeps the
|
|
13
|
+
* agent's prompt cache warm — only the trailing `extraMessages` and the response
|
|
14
|
+
* tokens are paid for; the rest of the prefix is served from cache.
|
|
15
|
+
*/
|
|
16
|
+
export type RunInferenceFn = (extraMessages: LLMMessage[]) => Promise<Result<InferenceResponse, LLMError>>;
|
|
8
17
|
/**
|
|
9
18
|
* Format a single message for summarization.
|
|
10
19
|
* Handles all message types including tool calls and tool results.
|
|
11
20
|
*/
|
|
12
21
|
export declare function formatMessageForSummary(msg: LLMMessage): string;
|
|
13
22
|
export interface CompactionConfig {
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated No longer used. Summarization runs on the agent's own model via
|
|
25
|
+
* the auxiliary inference callback so the agent's prompt cache is reused.
|
|
26
|
+
* Kept in the interface so existing preset configs continue to type-check.
|
|
27
|
+
*/
|
|
28
|
+
model?: ModelId;
|
|
29
|
+
/** Token threshold to trigger compaction. */
|
|
17
30
|
maxTokens: number;
|
|
18
|
-
/** Number of recent messages to keep uncompacted */
|
|
31
|
+
/** Number of recent messages to keep uncompacted. */
|
|
19
32
|
keepRecentMessages: number;
|
|
20
|
-
/** Max tokens for kept recent messages (whichever limit is hit first) */
|
|
33
|
+
/** Max tokens for kept recent messages (whichever limit is hit first). */
|
|
21
34
|
keepRecentTokens?: number;
|
|
22
|
-
/** Target token count after compaction (informational) */
|
|
35
|
+
/** Target token count after compaction (informational). */
|
|
23
36
|
targetTokens?: number;
|
|
24
|
-
/**
|
|
37
|
+
/** Optional override for the trailing summarization instruction sent to the model. */
|
|
25
38
|
summaryPrompt?: string;
|
|
26
|
-
/** Enable history offloading before compaction */
|
|
39
|
+
/** Enable history offloading before compaction. */
|
|
27
40
|
offloadHistory?: boolean;
|
|
28
|
-
/** Path prefix for offloaded history (default: /session/.history/) */
|
|
41
|
+
/** Path prefix for offloaded history (default: /session/.history/). */
|
|
29
42
|
historyPathPrefix?: string;
|
|
30
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Trailing user-message instruction appended to the agent's full prefix when
|
|
46
|
+
* requesting a summary. The model sees its real system prompt, tools and full
|
|
47
|
+
* conversation, then this instruction last. Phrased to discourage tool calls
|
|
48
|
+
* — Sonnet-class models reliably emit a plain text response under this prompt.
|
|
49
|
+
*/
|
|
50
|
+
export declare const DEFAULT_SUMMARY_INSTRUCTION: string;
|
|
31
51
|
export interface CompactionResult {
|
|
32
52
|
/** New messages to use (summary + kept messages) */
|
|
33
53
|
compactedMessages: LLMMessage[];
|
|
@@ -59,11 +79,10 @@ export interface HistoryOffloader {
|
|
|
59
79
|
offload(agentId: AgentId, content: string, pathPrefix: string): Promise<string>;
|
|
60
80
|
}
|
|
61
81
|
export declare class ContextCompactor {
|
|
62
|
-
private readonly llmProvider;
|
|
63
82
|
private readonly logger;
|
|
64
83
|
private readonly config;
|
|
65
84
|
private readonly historyOffloader?;
|
|
66
|
-
constructor(
|
|
85
|
+
constructor(logger: Logger, config: CompactionConfig, historyOffloader?: HistoryOffloader | undefined);
|
|
67
86
|
/**
|
|
68
87
|
* Compute how many recent messages to keep, respecting both count and token limits.
|
|
69
88
|
* Ensures the kept portion never starts with orphaned tool results (tool messages
|
|
@@ -71,18 +90,29 @@ export declare class ContextCompactor {
|
|
|
71
90
|
*/
|
|
72
91
|
private computeKeepCount;
|
|
73
92
|
/**
|
|
74
|
-
* Check if compaction is needed
|
|
93
|
+
* Check if compaction is needed.
|
|
94
|
+
*
|
|
95
|
+
* Prefers the provider-reported prompt token count from the previous turn
|
|
96
|
+
* (authoritative — comes straight from the model's tokenizer). Falls back
|
|
97
|
+
* to the in-process estimator when no previous metrics exist (first turn).
|
|
98
|
+
*
|
|
99
|
+
* The estimator under-counts JSON-heavy tool-result history by ~2x, so
|
|
100
|
+
* relying on it alone causes the trigger to never fire in long sessions.
|
|
75
101
|
*/
|
|
76
|
-
needsCompaction(messages: LLMMessage[]): boolean;
|
|
102
|
+
needsCompaction(messages: LLMMessage[], lastActualPromptTokens?: number): boolean;
|
|
77
103
|
/**
|
|
78
104
|
* Compact conversation history if needed.
|
|
79
105
|
* Returns null if compaction was not needed.
|
|
80
106
|
*/
|
|
81
|
-
compactIfNeeded(sessionId: SessionId, agentId: AgentId, messages: LLMMessage[]): Promise<Result<CompactionResult | null, Error>>;
|
|
107
|
+
compactIfNeeded(sessionId: SessionId, agentId: AgentId, messages: LLMMessage[], runInference: RunInferenceFn, lastActualPromptTokens?: number): Promise<Result<CompactionResult | null, Error>>;
|
|
82
108
|
/**
|
|
83
|
-
* Compact conversation history by
|
|
109
|
+
* Compact conversation history by asking the agent's own model to summarize
|
|
110
|
+
* the older portion. The summarization call reuses the agent's existing
|
|
111
|
+
* prompt cache via `runInference`, paying only for the trailing instruction
|
|
112
|
+
* (a few hundred tokens) and the summary output — not the whole conversation
|
|
113
|
+
* a second time.
|
|
84
114
|
*/
|
|
85
|
-
compact(sessionId: SessionId, agentId: AgentId, messages: LLMMessage[]): Promise<Result<CompactionResult, Error>>;
|
|
115
|
+
compact(sessionId: SessionId, agentId: AgentId, messages: LLMMessage[], runInference: RunInferenceFn, lastActualPromptTokens?: number): Promise<Result<CompactionResult, Error>>;
|
|
86
116
|
}
|
|
87
117
|
export declare function createContextCompactedEvent(sessionId: SessionId, agentId: AgentId, result: CompactionResult): ContextCompactedEvent;
|
|
88
118
|
//# sourceMappingURL=context-compactor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-compactor.d.ts","sourceRoot":"","sources":["../../../src/plugins/context-compact/context-compactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAgC,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAGlG,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"context-compactor.d.ts","sourceRoot":"","sources":["../../../src/plugins/context-compact/context-compactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAgC,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAGlG,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAGxD;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,KAAK,OAAO,CAAC,MAAM,CA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