@sayknow-cli/agent-core 0.2.7 → 0.3.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/CHANGELOG.md +6 -0
- package/dist/types/compaction/openai.d.ts +1 -0
- package/package.json +4 -4
- package/src/agent-loop.ts +11 -0
- package/src/compaction/openai.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.7.2] - 2026-06-24
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Reserved headroom when trimming OpenAI remote compaction input so `/responses/compact` requests stay below the model context window instead of filling the entire window.
|
|
10
|
+
|
|
5
11
|
## [0.6.2] - 2026-06-19
|
|
6
12
|
|
|
7
13
|
### Changed
|
|
@@ -43,6 +43,7 @@ export declare function getPreservedOpenAiRemoteCompactionData(preserveData: Rec
|
|
|
43
43
|
export declare function withOpenAiRemoteCompactionPreserveData(preserveData: Record<string, unknown> | undefined, remoteCompaction: OpenAiRemoteCompactionPreserveData | undefined): Record<string, unknown> | undefined;
|
|
44
44
|
export declare function estimateOpenAiCompactInputTokens(input: Array<Record<string, unknown>>, instructions: string): number;
|
|
45
45
|
export declare function trimOpenAiCompactInput(input: Array<Record<string, unknown>>, contextWindow: number, instructions: string): Array<Record<string, unknown>>;
|
|
46
|
+
export declare function resolveOpenAiCompactInputBudget(contextWindow: number, maxOutputTokens?: number): number;
|
|
46
47
|
/**
|
|
47
48
|
* Build the OpenAI Responses-API native history array from LLM messages.
|
|
48
49
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@sayknow-cli/agent-core",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
6
6
|
"homepage": "https://github.com/jaybeyond/Sayknow_CLI",
|
|
7
7
|
"author": "jaybeyond",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"fmt": "biome format --write ."
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@sayknow-cli/ai": "0.
|
|
39
|
-
"@sayknow-cli/natives": "0.
|
|
40
|
-
"@sayknow-cli/utils": "0.
|
|
38
|
+
"@sayknow-cli/ai": "0.3.1",
|
|
39
|
+
"@sayknow-cli/natives": "0.3.1",
|
|
40
|
+
"@sayknow-cli/utils": "0.3.1",
|
|
41
41
|
"@opentelemetry/api": "^1.9.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
package/src/agent-loop.ts
CHANGED
|
@@ -1084,6 +1084,17 @@ async function executeToolCalls(
|
|
|
1084
1084
|
|
|
1085
1085
|
await runInActiveSpan(toolSpan, async () => {
|
|
1086
1086
|
try {
|
|
1087
|
+
if (toolCall.incompleteArguments) {
|
|
1088
|
+
// The provider flagged this call's argument JSON as truncated
|
|
1089
|
+
// (the model hit its output-token limit mid-call). Executing the
|
|
1090
|
+
// best-effort partial parse would run the tool on wrong input, so
|
|
1091
|
+
// reject with a retryable, actionable error instead.
|
|
1092
|
+
throw new Error(
|
|
1093
|
+
`Tool call "${toolCall.name}" was cut off before its arguments finished streaming ` +
|
|
1094
|
+
`(the response hit its output token limit). The partial arguments cannot be executed. ` +
|
|
1095
|
+
`Re-issue the call with complete arguments, splitting the work into smaller steps if needed.`,
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1087
1098
|
if (!tool) throw new Error(`Tool ${toolCall.name} not found`);
|
|
1088
1099
|
|
|
1089
1100
|
let effectiveArgs: Record<string, unknown>;
|
package/src/compaction/openai.ts
CHANGED
|
@@ -237,6 +237,12 @@ export function trimOpenAiCompactInput(
|
|
|
237
237
|
return trimmed;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
export function resolveOpenAiCompactInputBudget(contextWindow: number, maxOutputTokens = 0): number {
|
|
241
|
+
if (contextWindow <= 0) return 0;
|
|
242
|
+
const reservedTokens = Math.max(Math.floor(contextWindow * 0.15), maxOutputTokens, 1);
|
|
243
|
+
return Math.max(1, contextWindow - reservedTokens);
|
|
244
|
+
}
|
|
245
|
+
|
|
240
246
|
function collectKnownOpenAiCallIds(items: Array<Record<string, unknown>>): Set<string> {
|
|
241
247
|
const knownCallIds = new Set<string>();
|
|
242
248
|
for (const item of items) {
|
|
@@ -473,7 +479,11 @@ export async function requestOpenAiRemoteCompaction(
|
|
|
473
479
|
const endpoint = resolveOpenAiCompactEndpoint(model, options?.authCredentialType);
|
|
474
480
|
const request: OpenAiRemoteCompactionRequest = {
|
|
475
481
|
model: model.id,
|
|
476
|
-
input: trimOpenAiCompactInput(
|
|
482
|
+
input: trimOpenAiCompactInput(
|
|
483
|
+
compactInput,
|
|
484
|
+
resolveOpenAiCompactInputBudget(model.contextWindow, model.maxTokens),
|
|
485
|
+
instructions,
|
|
486
|
+
),
|
|
477
487
|
instructions,
|
|
478
488
|
};
|
|
479
489
|
const headers: Record<string, string> = {
|