@lazyingart/agintiflow 0.20.328 → 0.20.329

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.
@@ -675,3 +675,28 @@ demonstrated evidence from inferred recommendations, and finished normally.
675
675
  The retained trace contains no completion-evidence rejection or forced
676
676
  source-mutation loop. Focused completion, evidence, progressive-tool, runtime,
677
677
  and dynamic-budget suites plus the full npm suite pass for `0.20.303`.
678
+
679
+ ### Response-only context compaction after provider handoff
680
+
681
+ `response-only-context-handoff-092` exercises a high-risk continuation boundary
682
+ for DeepSeek-first operation with LocalLLM fallback. Recent same-session
683
+ response-only evidence showed DeepSeek quota failures followed by LocalLLM
684
+ resume attempts that failed before inference because the retained transcript
685
+ exceeded the LocalLLM context window. Normal agent-step requests already had a
686
+ local context-budget compaction retry, but the explicit response-only branch
687
+ called the direct-response client without that recovery path.
688
+
689
+ AgInTiFlow now catches only `LOCALLLM_CONTEXT_BUDGET_EXCEEDED` in the
690
+ response-only branch, compacts the authoritative retained goal/evidence once,
691
+ persists `model.local_context_budget_exceeded` and
692
+ `history.compacted_for_local_context_retry`, and retries the same response-only
693
+ request with a bounded output reserve. The source-free evidence guard remains
694
+ active after compaction, so unsupported publication, validation, forecast,
695
+ benchmark, or metric claims still retry once and then fail closed.
696
+
697
+ The focused regression seeds a DeepSeek-owned response-only session, inflates
698
+ retained same-session context, resumes with a normal "answer from the saved
699
+ status" prompt, triggers a DeepSeek quota handoff, and verifies that LocalLLM is
700
+ called only after compaction. The run completes without `session.failed`, keeps
701
+ the provider handoff active on the same session, and records the compaction
702
+ events as durable evidence.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.328",
3
+ "version": "0.20.329",
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",
@@ -4155,6 +4155,72 @@ function responseOnlySourceFreeStopResult(assessment = {}) {
4155
4155
  }
4156
4156
 
4157
4157
  async function finishWithResponseOnlyModelTurn({ client, config, state, store, observers, sessionId }) {
4158
+ async function requestWithResponseOnlyLocalContextRecovery({ step, mode }) {
4159
+ try {
4160
+ return await requestDirectResponse(client, config, state.messages);
4161
+ } catch (error) {
4162
+ if (!isLocalContextBudgetError(error)) throw error;
4163
+ state.meta = state.meta || {};
4164
+ const retried = state.meta.localContextBudgetRetries || {};
4165
+ const retryKey = `response-only:${mode}`;
4166
+ if (retried[retryKey]) throw error;
4167
+
4168
+ const requestMessages = Array.isArray(state.messages) ? state.messages : [];
4169
+ const currentOutputTokens = Math.max(0, Number(config.maxOutputTokens || 0));
4170
+ const retryOutputTokens = currentOutputTokens
4171
+ ? Math.min(currentOutputTokens, 4096)
4172
+ : 4096;
4173
+ const retryRuntimeConfig = {
4174
+ ...config,
4175
+ maxOutputTokens: retryOutputTokens,
4176
+ };
4177
+ const compactMessages = buildContextBudgetCompactionMessages(
4178
+ state,
4179
+ retryRuntimeConfig,
4180
+ null,
4181
+ step,
4182
+ {
4183
+ heading: "A response-only LocalLLM request exceeded the local context window.",
4184
+ detail: redactSensitiveText(error instanceof Error ? error.message : String(error)),
4185
+ recoveryInstruction:
4186
+ "Answer the current response-only request directly from the compacted authoritative context above. Do not claim fresh external evidence unless the compacted context contains a current evidence manifest or scoped tool evidence.",
4187
+ }
4188
+ );
4189
+ const detail = {
4190
+ step,
4191
+ mode,
4192
+ provider: config.provider,
4193
+ model: config.model,
4194
+ messageCharsBefore: countMessageChars(requestMessages),
4195
+ messageCharsAfter: countMessageChars(compactMessages),
4196
+ messageTokensBefore: estimateMessageTokens(requestMessages),
4197
+ messageTokensAfter: estimateMessageTokens(compactMessages),
4198
+ maxOutputTokens: retryOutputTokens,
4199
+ error: redactSensitiveText(error instanceof Error ? error.message : String(error)),
4200
+ };
4201
+ state.messages = compactMessages;
4202
+ resetStaticDiscoveryAfterContextLoss(state, "response-only-local-context-budget-retry", {
4203
+ preserveStaticEvidence: true,
4204
+ });
4205
+ state.meta.localContextBudgetRetries = {
4206
+ ...retried,
4207
+ [retryKey]: true,
4208
+ };
4209
+ state.meta.lastResponseOnlyContextBudgetRecovery = detail;
4210
+ await store.appendEvent("model.local_context_budget_exceeded", detail);
4211
+ await store.appendEvent("history.compacted_for_local_context_retry", detail);
4212
+ observers.event("model.local_context_budget_exceeded", detail);
4213
+ observers.event("history.compacted_for_local_context_retry", detail);
4214
+ emitConsole(
4215
+ config,
4216
+ "Local provider context exceeded its configured window for a response-only turn; compacted authoritative context and retrying once.",
4217
+ { kind: "meta" }
4218
+ );
4219
+ await store.saveState(state);
4220
+ return await requestDirectResponse(client, retryRuntimeConfig, state.messages);
4221
+ }
4222
+ }
4223
+
4158
4224
  await store.appendEvent("model.requested", {
4159
4225
  step: 1,
4160
4226
  provider: config.provider,
@@ -4168,7 +4234,10 @@ async function finishWithResponseOnlyModelTurn({ client, config, state, store, o
4168
4234
  mode: "response-only",
4169
4235
  });
4170
4236
 
4171
- const response = await requestDirectResponse(client, config, state.messages);
4237
+ const response = await requestWithResponseOnlyLocalContextRecovery({
4238
+ step: 1,
4239
+ mode: "response-only",
4240
+ });
4172
4241
  const rawAssistantMessage = response.choices[0]?.message;
4173
4242
  let result = responseOnlyResultFromMessage(rawAssistantMessage);
4174
4243
  let finalAssistantMessage = rawAssistantMessage;
@@ -4208,7 +4277,10 @@ async function finishWithResponseOnlyModelTurn({ client, config, state, store, o
4208
4277
  model: config.model,
4209
4278
  mode: "response-only-repair",
4210
4279
  });
4211
- const repairResponse = await requestDirectResponse(client, config, state.messages);
4280
+ const repairResponse = await requestWithResponseOnlyLocalContextRecovery({
4281
+ step: 2,
4282
+ mode: "response-only-repair",
4283
+ });
4212
4284
  finalAssistantMessage = repairResponse.choices[0]?.message;
4213
4285
  result = responseOnlyResultFromMessage(finalAssistantMessage);
4214
4286
  sourceFreeAssessment = await assessResponseOnlySourceFreeClaims({