@sayknow-cli/agent-core 0.7.9 → 0.7.11

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 CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.7.11] - 2026-10-22
6
+
7
+ ## [0.7.10] - 2026-10-20
8
+
9
+ ### Changed
10
+
11
+ - The post-compaction context message now presents the summary as this session's compacted work state instead of "a summary of another language model's thinking process". The old framing read as handing over another model's reasoning and correlated with Anthropic `reasoning_extraction` refusals in long sessions.
12
+ - The compaction summary, compaction update, and handoff-document prompts no longer describe the summary as written "for another LLM" or "another instance of yourself"; they describe resuming the task after older context is dropped.
13
+ - Compaction keeps the category of a provider refusal (`Refusal (<category>)`) but replaces the provider's explanation with `[provider explanation omitted]` in serialized conversations, previous summaries, stored summaries, and rendered summary context. The "preserve exact error messages" rule otherwise copied the policy prose into every later summary and re-sent it on every request.
14
+
5
15
  ## [0.7.9] - 2026-10-17
6
16
 
7
17
  ### Changed
@@ -23,6 +23,8 @@ export declare function computeFileLists(fileOps: FileOperations): {
23
23
  };
24
24
  export declare function formatFileOperations(readFiles: string[], modifiedFiles: string[]): string;
25
25
  export declare function upsertFileOperations(summary: string, readFiles: string[], modifiedFiles: string[]): string;
26
+ export declare const PROVIDER_REFUSAL_EXPLANATION_OMITTED = "[provider explanation omitted]";
27
+ export declare function redactProviderRefusalExplanations(text: string): string;
26
28
  /**
27
29
  * Serialize LLM messages to text for summarization.
28
30
  * This prevents the model from treating it as a conversation to continue.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@sayknow-cli/agent-core",
4
- "version": "0.7.9",
4
+ "version": "0.7.11",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://sayknow-cli.com",
7
7
  "author": "jaybeyond",
@@ -35,9 +35,9 @@
35
35
  "fmt": "biome format --write ."
36
36
  },
37
37
  "dependencies": {
38
- "@sayknow-cli/ai": "0.7.9",
39
- "@sayknow-cli/natives": "0.7.9",
40
- "@sayknow-cli/utils": "0.7.9",
38
+ "@sayknow-cli/ai": "0.7.11",
39
+ "@sayknow-cli/natives": "0.7.11",
40
+ "@sayknow-cli/utils": "0.7.11",
41
41
  "@opentelemetry/api": "^1.9.0"
42
42
  },
43
43
  "devDependencies": {
@@ -40,6 +40,7 @@ import {
40
40
  createFileOps,
41
41
  extractFileOpsFromMessage,
42
42
  type FileOperations,
43
+ redactProviderRefusalExplanations,
43
44
  SUMMARIZATION_SYSTEM_PROMPT,
44
45
  serializeConversation,
45
46
  upsertFileOperations,
@@ -1023,7 +1024,7 @@ export async function generateSummary(
1023
1024
  // Build the prompt with conversation wrapped in tags
1024
1025
  let promptText = `<conversation>\n${conversationText}\n</conversation>\n\n`;
1025
1026
  if (previousSummary) {
1026
- promptText += `<previous-summary>\n${previousSummary}\n</previous-summary>\n\n`;
1027
+ promptText += `<previous-summary>\n${redactProviderRefusalExplanations(previousSummary)}\n</previous-summary>\n\n`;
1027
1028
  }
1028
1029
  promptText += formatAdditionalContext(options?.extraContext);
1029
1030
  promptText += basePrompt;
@@ -1560,7 +1561,7 @@ export async function compact(
1560
1561
 
1561
1562
  // Compute file lists and append to summary
1562
1563
  const { readFiles, modifiedFiles } = computeFileLists(fileOps);
1563
- summary = upsertFileOperations(summary, readFiles, modifiedFiles);
1564
+ summary = upsertFileOperations(redactProviderRefusalExplanations(summary), readFiles, modifiedFiles);
1564
1565
  const shortSummary = deriveShortSummary(summary);
1565
1566
 
1566
1567
  if (!firstKeptEntryId) {
@@ -11,6 +11,7 @@ import { prompt } from "@sayknow-cli/utils";
11
11
  import type { AgentMessage } from "../types";
12
12
  import branchSummaryContextPrompt from "./prompts/branch-summary-context.md" with { type: "text" };
13
13
  import compactionSummaryContextPrompt from "./prompts/compaction-summary-context.md" with { type: "text" };
14
+ import { redactProviderRefusalExplanations } from "./utils";
14
15
 
15
16
  const COMPACTION_SUMMARY_TEMPLATE = compactionSummaryContextPrompt;
16
17
  const BRANCH_SUMMARY_TEMPLATE = branchSummaryContextPrompt;
@@ -76,11 +77,13 @@ function getPrunedToolResultContent(message: ToolResultMessage): (TextContent |
76
77
  }
77
78
 
78
79
  export function renderBranchSummaryContext(summary: string): string {
79
- return prompt.render(BRANCH_SUMMARY_TEMPLATE, { summary });
80
+ return prompt.render(BRANCH_SUMMARY_TEMPLATE, { summary: redactProviderRefusalExplanations(summary) });
80
81
  }
81
82
 
83
+ // Summaries persisted before refusal redaction existed still carry the provider's
84
+ // explanation; redact at render time so stored sessions stop re-sending it.
82
85
  export function renderCompactionSummaryContext(summary: string): string {
83
- return prompt.render(COMPACTION_SUMMARY_TEMPLATE, { summary });
86
+ return prompt.render(COMPACTION_SUMMARY_TEMPLATE, { summary: redactProviderRefusalExplanations(summary) });
84
87
  }
85
88
 
86
89
  export function createBranchSummaryMessage(summary: string, fromId: string, timestamp: string): BranchSummaryMessage {
@@ -1,4 +1,4 @@
1
- Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. You MUST use this to build on the work that has already been done and NEVER duplicate work. Here is the summary produced by the other language model; you MUST use the information in this summary to assist with your own analysis:
1
+ Earlier turns of this session were compacted to save context. The summary below records the work completed so far, the decisions made, and the current state of the task; the files and tool state it describes are still in place. Continue the task from this state: build on the completed work and NEVER redo it.
2
2
 
3
3
  <summary>
4
4
  {{summary}}
@@ -1,4 +1,4 @@
1
- You MUST summarize the conversation above into a structured context checkpoint handoff summary for another LLM to resume task.
1
+ You MUST summarize the conversation above into a structured context checkpoint handoff summary so the task can resume from it after older context is dropped.
2
2
 
3
3
  IMPORTANT: If conversation ends with unanswered question to user or imperative/request awaiting user response (e.g., "Please run command and paste output"), you MUST preserve that exact question/request.
4
4
 
@@ -1,4 +1,4 @@
1
- You MUST incorporate new messages above into the existing handoff summary in <previous-summary> tags, used by another LLM to resume task.
1
+ You MUST incorporate new messages above into the existing handoff summary in <previous-summary> tags; the task resumes from this summary after older context is dropped.
2
2
  RULES:
3
3
  - MUST preserve all information from previous summary
4
4
  - MUST add new progress, decisions, and context from new messages
@@ -1,5 +1,5 @@
1
1
  <critical>
2
- Write a handoff document for another instance of yourself.
2
+ Write a handoff document so this work can continue in a fresh session.
3
3
  The handoff MUST be sufficient for seamless continuation without access to this conversation.
4
4
  Output ONLY the handoff document. No preamble, no commentary, no wrapper text.
5
5
  </critical>
@@ -118,6 +118,20 @@ function truncateForSummary(text: string, maxChars: number): string {
118
118
  return `${text.slice(0, maxChars)}\n\n[... ${truncatedChars} more characters truncated]`;
119
119
  }
120
120
 
121
+ /**
122
+ * Provider refusal errors render as `Refusal (<category>): <explanation>` (see the
123
+ * Anthropic adapter). The explanation is the provider's own policy prose; once it
124
+ * lands in a compaction summary, the "preserve exact error messages" rule copies it
125
+ * into every later summary and re-sends it with every request. Keep the category,
126
+ * which is what the work needs, and drop the explanation.
127
+ */
128
+ const PROVIDER_REFUSAL_EXPLANATION = /\bRefusal \(([A-Za-z0-9_.-]+)\): [^\n`"]+/g;
129
+ export const PROVIDER_REFUSAL_EXPLANATION_OMITTED = "[provider explanation omitted]";
130
+
131
+ export function redactProviderRefusalExplanations(text: string): string {
132
+ return text.replace(PROVIDER_REFUSAL_EXPLANATION, `Refusal ($1): ${PROVIDER_REFUSAL_EXPLANATION_OMITTED}`);
133
+ }
134
+
121
135
  /**
122
136
  * Serialize LLM messages to text for summarization.
123
137
  * This prevents the model from treating it as a conversation to continue.
@@ -175,7 +189,7 @@ export function serializeConversation(messages: Message[]): string {
175
189
  }
176
190
  }
177
191
 
178
- return parts.join("\n\n");
192
+ return redactProviderRefusalExplanations(parts.join("\n\n"));
179
193
  }
180
194
 
181
195
  // ============================================================================