@lazyingart/agintiflow 0.20.243 → 0.20.244

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.243",
3
+ "version": "0.20.244",
4
4
  "type": "module",
5
5
  "description": "AgInTiFlow is a project-aware agent workspace for hybrid wet-dry R&D, hardware-aware intelligence, software automation, and industrial workflows.",
6
6
  "license": "Apache-2.0",
@@ -125,57 +125,94 @@ const sentPlan = capturedPayload.messages.map((message) => message.content || ""
125
125
  assert.ok(sentPlan.includes(HEAD), "plan request lost the exact task head");
126
126
  assert.ok(sentPlan.includes(TAIL), "plan request lost the latest task tail");
127
127
 
128
+ const compactionState = {
129
+ goal: hugeGoal,
130
+ plan: "Use the existing routine and verify its artifact.",
131
+ messages: [
132
+ { role: "system", content: "SYSTEM-HEAD\n" + "policy ".repeat(10000) + "\nSYSTEM-TAIL" },
133
+ { role: "user", content: "first request" },
134
+ {
135
+ role: "user",
136
+ content:
137
+ "The runtime proactively compacted a long agent history before the provider context became inefficient or unstable. OLD-COMPACTION-MUST-NOT-RECUR",
138
+ },
139
+ {
140
+ role: "assistant",
141
+ content: "",
142
+ tool_calls: [
143
+ {
144
+ id: "deep-research-complete",
145
+ type: "function",
146
+ function: {
147
+ name: "deep_research",
148
+ arguments: '{"query":"reliability evidence","outputPath":"reports/reliability.md"}',
149
+ },
150
+ },
151
+ ],
152
+ },
153
+ {
154
+ role: "tool",
155
+ tool_call_id: "deep-research-complete",
156
+ content: JSON.stringify({
157
+ ok: true,
158
+ toolName: "deep_research",
159
+ version: 14,
160
+ researchId: "reliability-evidence-v14",
161
+ status: "completed",
162
+ stage: "completed",
163
+ reportPath: "reports/reliability.md",
164
+ artifactPath: ".aginti/deep-research-reliability.json",
165
+ queryCount: 10,
166
+ sourceCount: 16,
167
+ coverage: { requiredFirstPartyVerified: true },
168
+ audit: { citationCoverage: 1 },
169
+ }),
170
+ },
171
+ {
172
+ role: "tool",
173
+ content: JSON.stringify({
174
+ ok: true,
175
+ toolName: "read_file",
176
+ path: "/evidence/Musia/SKILL.md",
177
+ bytes: 2048,
178
+ sha256: "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
179
+ contentTruncated: false,
180
+ content: [
181
+ "---",
182
+ "name: musia-music-production",
183
+ "description: Create and review songs through the established Musia production workflow.",
184
+ "---",
185
+ "# Musia Music Production",
186
+ "Use the existing CLI and preserve the reviewed song artifacts.",
187
+ ].join("\n"),
188
+ commandEvidence: [{ command: "node bin/musia.js doctor --json" }],
189
+ pathEvidence: [{ path: "bin/musia.js" }],
190
+ }),
191
+ },
192
+ {
193
+ role: "tool",
194
+ content: JSON.stringify({
195
+ ok: true,
196
+ toolName: "list_files",
197
+ path: "/evidence/LALACHAN/scripts",
198
+ entries: [{ path: "scripts/xyq_cdp_browser.py" }, { path: "scripts/wait_downloaded_mp4.sh" }],
199
+ }),
200
+ },
201
+ { role: "user", content: "latest interruption: send the finished PDF to this exact chat" },
202
+ ],
203
+ };
128
204
  const runtimeMessages = buildContextBudgetCompactionMessages(
129
- {
130
- goal: hugeGoal,
131
- plan: "Use the existing routine and verify its artifact.",
132
- messages: [
133
- { role: "system", content: "SYSTEM-HEAD\n" + "policy ".repeat(10000) + "\nSYSTEM-TAIL" },
134
- { role: "user", content: "first request" },
135
- {
136
- role: "user",
137
- content:
138
- "The runtime proactively compacted a long agent history before the provider context became inefficient or unstable. OLD-COMPACTION-MUST-NOT-RECUR",
139
- },
140
- {
141
- role: "tool",
142
- content: JSON.stringify({
143
- ok: true,
144
- toolName: "read_file",
145
- path: "/evidence/Musia/SKILL.md",
146
- bytes: 2048,
147
- sha256: "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
148
- contentTruncated: false,
149
- content: [
150
- "---",
151
- "name: musia-music-production",
152
- "description: Create and review songs through the established Musia production workflow.",
153
- "---",
154
- "# Musia Music Production",
155
- "Use the existing CLI and preserve the reviewed song artifacts.",
156
- ].join("\n"),
157
- commandEvidence: [{ command: "node bin/musia.js doctor --json" }],
158
- pathEvidence: [{ path: "bin/musia.js" }],
159
- }),
160
- },
161
- {
162
- role: "tool",
163
- content: JSON.stringify({
164
- ok: true,
165
- toolName: "list_files",
166
- path: "/evidence/LALACHAN/scripts",
167
- entries: [{ path: "scripts/xyq_cdp_browser.py" }, { path: "scripts/wait_downloaded_mp4.sh" }],
168
- }),
169
- },
170
- { role: "user", content: "latest interruption: send the finished PDF to this exact chat" },
171
- ],
172
- },
205
+ compactionState,
173
206
  config,
174
207
  { title: "", url: "" },
175
208
  3,
176
209
  { reason: "test context recovery" }
177
210
  );
178
211
  const runtimeText = runtimeMessages.map((message) => message.content || "").join("\n");
212
+ const retainedNativeDeepResearch = runtimeMessages.find((message) =>
213
+ Array.isArray(message.tool_calls) &&
214
+ message.tool_calls.some((call) => call?.function?.name === "deep_research")
215
+ );
179
216
  assert.ok(
180
217
  estimateMessageTokens(runtimeMessages) <= 12288,
181
218
  "runtime compaction exceeded the bounded LocalLLM retry target"
@@ -193,8 +230,27 @@ assert.ok(runtimeText.includes("sha256=1234567890abcdef"));
193
230
  assert.ok(runtimeText.includes("content=complete"));
194
231
  assert.ok(runtimeText.includes("node bin/musia.js doctor --json"));
195
232
  assert.ok(runtimeText.includes("scripts/xyq_cdp_browser.py"));
233
+ assert.ok(retainedNativeDeepResearch, "native compaction lost the completed deep_research call");
234
+ assert.ok(runtimeText.includes("reliability-evidence-v14"));
235
+ assert.ok(runtimeText.includes('"version":14'));
196
236
  assert.ok(!runtimeText.includes("OLD-COMPACTION-MUST-NOT-RECUR"));
197
237
  assert.match(runtimeText, /Do not reread a listed source solely because compaction occurred/);
198
238
  assert.match(runtimeText, /never restart a full-file read loop after compaction/);
199
239
 
240
+ const deepSeekRuntimeMessages = buildContextBudgetCompactionMessages(
241
+ compactionState,
242
+ { ...config, provider: "deepseek", model: "deepseek-chat" },
243
+ { title: "", url: "" },
244
+ 3,
245
+ { reason: "test DeepSeek context recovery" }
246
+ );
247
+ const deepSeekRuntimeText = deepSeekRuntimeMessages.map((message) => message.content || "").join("\n");
248
+ assert.ok(deepSeekRuntimeText.includes("Tool: deep_research"));
249
+ assert.ok(deepSeekRuntimeText.includes("reliability-evidence-v14"));
250
+ assert.ok(deepSeekRuntimeText.includes('"version":14'));
251
+ assert.ok(
252
+ estimateMessageTokens(deepSeekRuntimeMessages) <= 12288,
253
+ "DeepSeek runtime compaction exceeded the bounded retry target"
254
+ );
255
+
200
256
  console.log("context budget recovery smoke passed");
@@ -1515,6 +1515,36 @@ sameNames(
1515
1515
  ["deep_research", "finish"],
1516
1516
  "local evidence research did not enter the bounded research engine after inspection"
1517
1517
  );
1518
+ const localEvidenceAfterDeepResearchCompaction = selectProgressiveTools(allTools, {
1519
+ config: { provider: "deepseek" },
1520
+ goal:
1521
+ "Investigate the reliability problem in this folder, correct PROJECT_NOTES.md, write an evidence review and sources.json, then commit the intentional work.",
1522
+ profile: "research",
1523
+ messages: [
1524
+ {
1525
+ role: "user",
1526
+ content:
1527
+ "The runtime proactively compacted a long agent history before the provider context became inefficient or unstable.",
1528
+ },
1529
+ {
1530
+ role: "user",
1531
+ content: [
1532
+ "Retained runtime tool evidence. This operation already completed; use its result and do not repeat it solely because context was compacted.",
1533
+ "Tool: deep_research",
1534
+ 'Arguments: {"query":"reliability evidence"}',
1535
+ 'Verified result: {"ok":true,"version":14,"status":"completed"}',
1536
+ ].join("\n"),
1537
+ },
1538
+ ],
1539
+ });
1540
+ assert(
1541
+ names(localEvidenceAfterDeepResearchCompaction).includes("read_file"),
1542
+ "post-research compaction did not restore local workspace tools"
1543
+ );
1544
+ assert(
1545
+ !(names(localEvidenceAfterDeepResearchCompaction).length === 2 && names(localEvidenceAfterDeepResearchCompaction)[0] === "deep_research"),
1546
+ "post-research compaction forgot the completed bounded research call"
1547
+ );
1518
1548
 
1519
1549
  const documentRuntimeSnapshot =
1520
1550
  'Step 1/30. Latest runtime snapshot:\n{"pageText":"Workspace file tools are ready. Web search and resumable deep research are available when current evidence is required."}';
@@ -881,6 +881,7 @@ function summarizeRetainedSourceEvidence(messages = [], limit = 28) {
881
881
 
882
882
  const COMPACTION_STATE_TOOL_NAMES = new Set([
883
883
  "inspect_project",
884
+ "deep_research",
884
885
  "read_file",
885
886
  "list_files",
886
887
  "search_files",
@@ -923,6 +924,17 @@ function compactRetainedToolPayload(toolName, payload = {}, args = {}) {
923
924
  result.sourceDirs = compactPathItems(payload.sourceDirs, 16, ["path", "kind"]);
924
925
  result.topLevel = compactPathItems(payload.topLevel, 32, ["path", "type", "size"]);
925
926
  result.files = compactPathItems(payload.files, 48, ["path", "size"]);
927
+ } else if (toolName === "deep_research") {
928
+ result.version = Number(payload.version || 0);
929
+ result.researchId = compactSingleLine(payload.researchId, 180);
930
+ result.status = compactSingleLine(payload.status, 80);
931
+ result.stage = compactSingleLine(payload.stage, 80);
932
+ result.reportPath = compactSingleLine(payload.reportPath, 500);
933
+ result.artifactPath = compactSingleLine(payload.artifactPath, 500);
934
+ result.queryCount = Math.max(0, Number(payload.queryCount || 0));
935
+ result.sourceCount = Math.max(0, Number(payload.sourceCount || 0));
936
+ result.coverage = payload.coverage && typeof payload.coverage === "object" ? payload.coverage : {};
937
+ result.audit = payload.audit && typeof payload.audit === "object" ? payload.audit : {};
926
938
  } else if (toolName === "read_file") {
927
939
  if (Number.isFinite(Number(payload.bytes))) result.bytes = Number(payload.bytes);
928
940
  const content = String(payload.content || payload.contentPreview || "");
@@ -981,11 +993,13 @@ function retainedToolStateMessages(messages = [], limit = 12) {
981
993
  }
982
994
 
983
995
  const records = [...recordsByKey.values()];
984
- const latestInspection = [...records].reverse().find((record) => record.name === "inspect_project");
996
+ const pinned = ["inspect_project", "deep_research"]
997
+ .map((name) => [...records].reverse().find((record) => record.name === name))
998
+ .filter(Boolean);
985
999
  const remaining = records
986
- .filter((record) => record !== latestInspection)
987
- .slice(-Math.max(0, Number(limit) - (latestInspection ? 1 : 0)));
988
- const selected = [latestInspection, ...remaining].filter(Boolean).sort((left, right) => left.ordinal - right.ordinal);
1000
+ .filter((record) => !pinned.includes(record))
1001
+ .slice(-Math.max(0, Number(limit) - pinned.length));
1002
+ const selected = [...pinned, ...remaining].sort((left, right) => left.ordinal - right.ordinal);
989
1003
 
990
1004
  return selected.flatMap((record, index) => {
991
1005
  const id = `aginti-compacted-tool-${index + 1}`;