@kingsoftcloud/agentkit-harness-core 0.0.29 → 0.0.30

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.
@@ -927,6 +927,8 @@ export interface RunSnapshot extends RunIdentity {
927
927
  toolErrorStreak: ToolErrorStreak | null;
928
928
  toolErrorRecovery?: ToolErrorRecovery | null;
929
929
  deliveryReview?: DeliveryReviewState | null;
930
+ /** Last unfinished delivery sent back to the model, keyed by work progress. */
931
+ deliveryContinuationDigest?: string;
930
932
  executionBudgetObservation?: {
931
933
  policy: 'prepared-execution-budget/v1';
932
934
  runId: string;
package/dist/kernel.mjs CHANGED
@@ -827,6 +827,11 @@ export class NativeKernel {
827
827
  facts.push({ kind: 'context.summary_completed', payload: { kind: result.kind, usage: objectValue(result.usage),
828
828
  messageCursor: snapshot.messages.length, usageReported: result.usageReported !== false,
829
829
  proposalAvailable: !!changes.contextState?.compaction?.proposal } });
830
+ if (typeof changes.retryNotBefore === 'number' && changes.retryNotBefore > 0)
831
+ facts.push({ kind: 'model.retry_scheduled', payload: { retryAt: Math.ceil(changes.retryNotBefore), purpose: 'compaction',
832
+ attempt: result.kind === 'provider_retryable_error' ? changes.contextState?.compaction?.providerErrors ?? 1
833
+ : changes.contextState?.compaction?.errors ?? 1,
834
+ ...(result.failureDiagnostic ? { failure: objectValue(result.failureDiagnostic) } : {}) } });
830
835
  break;
831
836
  }
832
837
  const request = this.taskModelRequest(context, snapshot, configuration, intent);
@@ -875,6 +880,7 @@ export class NativeKernel {
875
880
  toolCalls: planning ? [] : result.toolCalls.map(objectValue), usage: objectValue(result.usage) } });
876
881
  if (typeof changes.retryNotBefore === 'number' && changes.retryNotBefore > 0)
877
882
  facts.push({ kind: 'model.retry_scheduled', payload: { retryAt: Math.ceil(changes.retryNotBefore),
883
+ attempt: result.kind === 'provider_retryable_error' ? changes.providerErrors ?? 1 : changes.modelErrors ?? 1,
878
884
  ...(result.failureDiagnostic ? { failure: objectValue(result.failureDiagnostic) } : {}) } });
879
885
  break;
880
886
  }
package/dist/machine.mjs CHANGED
@@ -292,8 +292,25 @@ export function plan(snapshot, config, capabilities, digest = canonical, policie
292
292
  invariant(snapshot.candidate, 'verification_candidate_missing');
293
293
  if (!capabilities.verification) {
294
294
  const review = policies.forRun(config).review.scheduleDeliveryReview(snapshot, config, 'verification_report_missing', digest);
295
- return review ? transition(snapshot, review, [{ kind: 'completion.delivery_review_started', payload: {} }])
296
- : finalizing(snapshot, 'unverified', 'verification_report_missing');
295
+ if (review)
296
+ return transition(snapshot, review, [{ kind: 'completion.delivery_review_started', payload: {} }]);
297
+ const remaining = snapshot.todos?.items.filter(item => item.status !== 'completed') ?? [];
298
+ if (config.todoPolicy === 'session-todos/v1' && snapshot.candidate.purpose !== 'checkpoint'
299
+ && snapshot.lastWorkspaceMutationToolCall != null && remaining.length) {
300
+ const progress = digest({ goal: snapshot.goalRevision, workspace: snapshot.workspaceRevision,
301
+ checks: remaining.map(item => item.content).sort() });
302
+ const reason = snapshot.deliveryContinuationDigest === progress ? 'delivery_no_progress'
303
+ : snapshot.repairs >= config.limits.maxRepairs || finalizationOnly(snapshot, config)
304
+ || toolRoom(snapshot, config) <= 0 || wallDeliveryOnly(snapshot, config) ? 'delivery_repair_budget_exhausted' : null;
305
+ if (reason)
306
+ return transition(snapshot, { phase: 'paused', resumePhase: 'preparing_context', candidate: null, reason, outcome: null }, [{ kind: 'run.paused', payload: { reason } }]);
307
+ return transition(snapshot, { phase: 'preparing_context', candidate: null, preparedContext: null,
308
+ repairs: snapshot.repairs + 1, deliveryContinuationDigest: progress, messages: [...snapshot.messages,
309
+ { role: 'user', kind: 'verification_observation', content: canonical({ reason: 'delivery_todos_incomplete',
310
+ remaining: remaining.map(item => item.content),
311
+ instruction: 'The preceding draft was a progress report. Continue from the current workspace. Use committed tool results to identify and repair failures, run the remaining checks, and update the checklist only with observed results. If a concrete blocker requires the user, ask for the required input.' }) }] }, [{ kind: 'completion.continued', payload: { reason: 'delivery_todos_incomplete' } }]);
312
+ }
313
+ return finalizing(snapshot, 'unverified', 'verification_report_missing');
297
314
  }
298
315
  return prepareEffect(snapshot, 'verify', 'verifying', { candidate: objectValue(snapshot.candidate) });
299
316
  }
@@ -161,7 +161,8 @@ export function reduceCommand(snapshot, command, pending = null, bindings = {})
161
161
  ...(snapshot.reasoningStallRetry ? { reasoningStallRetry: false } : {}) } : {}),
162
162
  ...(bindings.configuration?.approvalOutcomePolicy === APPROVAL_OUTCOME_POLICY
163
163
  && ['approval_rejected', 'approval_cancelled', 'approval_unavailable'].includes(snapshot.reason ?? '') ? { reason: null } : {}),
164
- ...(['provider_unavailable', 'context_summary_unavailable', 'context_source_unavailable', 'child_paused']
164
+ ...(['provider_unavailable', 'context_summary_unavailable', 'context_source_unavailable', 'child_paused',
165
+ 'delivery_no_progress', 'delivery_repair_budget_exhausted']
165
166
  .includes(snapshot.reason ?? '') ? { reason: null } : {}) };
166
167
  break;
167
168
  case 'submit_interaction': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingsoftcloud/agentkit-harness-core",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Host-independent Native Harness contracts, transitions and durable execution.",
package/src/contracts.mts CHANGED
@@ -526,6 +526,8 @@ export interface RunSnapshot extends RunIdentity {
526
526
  toolErrorStreak: ToolErrorStreak | null;
527
527
  toolErrorRecovery?: ToolErrorRecovery | null;
528
528
  deliveryReview?: DeliveryReviewState | null;
529
+ /** Last unfinished delivery sent back to the model, keyed by work progress. */
530
+ deliveryContinuationDigest?: string;
529
531
  executionBudgetObservation?: { policy: 'prepared-execution-budget/v1'; runId: string; sourceRevision: number;
530
532
  goalRevision: number; modelCallsClaimed: number; toolCallsClaimed: number; wallMsRemaining: number | null };
531
533
  deliveryArtifacts?: { goalRevision: number; paths: string[] };
package/src/kernel.mts CHANGED
@@ -720,6 +720,11 @@ export class NativeKernel {
720
720
  facts.push({ kind: 'context.summary_completed', payload: { kind: result.kind, usage: objectValue(result.usage),
721
721
  messageCursor: snapshot.messages.length, usageReported: result.usageReported !== false,
722
722
  proposalAvailable: !!changes.contextState?.compaction?.proposal } });
723
+ if (typeof changes.retryNotBefore === 'number' && changes.retryNotBefore > 0)
724
+ facts.push({ kind: 'model.retry_scheduled', payload: { retryAt: Math.ceil(changes.retryNotBefore), purpose: 'compaction',
725
+ attempt: result.kind === 'provider_retryable_error' ? changes.contextState?.compaction?.providerErrors ?? 1
726
+ : changes.contextState?.compaction?.errors ?? 1,
727
+ ...(result.failureDiagnostic ? { failure: objectValue(result.failureDiagnostic) } : {}) } });
723
728
  break;
724
729
  }
725
730
  const request = this.taskModelRequest(context, snapshot, configuration, intent);
@@ -767,6 +772,7 @@ export class NativeKernel {
767
772
  toolCalls: planning ? [] : result.toolCalls.map(objectValue), usage: objectValue(result.usage) } });
768
773
  if (typeof changes.retryNotBefore === 'number' && changes.retryNotBefore > 0)
769
774
  facts.push({ kind: 'model.retry_scheduled', payload: { retryAt: Math.ceil(changes.retryNotBefore),
775
+ attempt: result.kind === 'provider_retryable_error' ? changes.providerErrors ?? 1 : changes.modelErrors ?? 1,
770
776
  ...(result.failureDiagnostic ? { failure: objectValue(result.failureDiagnostic) } : {}) } });
771
777
  break;
772
778
  }
package/src/machine.mts CHANGED
@@ -274,8 +274,25 @@ export function plan(snapshot: RunSnapshot, config: RunConfiguration, capabiliti
274
274
  invariant(snapshot.candidate, 'verification_candidate_missing');
275
275
  if (!capabilities.verification) {
276
276
  const review = policies.forRun(config).review.scheduleDeliveryReview(snapshot, config, 'verification_report_missing', digest);
277
- return review ? transition(snapshot, review, [{ kind: 'completion.delivery_review_started', payload: {} }])
278
- : finalizing(snapshot, 'unverified', 'verification_report_missing');
277
+ if (review) return transition(snapshot, review, [{ kind: 'completion.delivery_review_started', payload: {} }]);
278
+ const remaining = snapshot.todos?.items.filter(item => item.status !== 'completed') ?? [];
279
+ if (config.todoPolicy === 'session-todos/v1' && snapshot.candidate.purpose !== 'checkpoint'
280
+ && snapshot.lastWorkspaceMutationToolCall != null && remaining.length) {
281
+ const progress = digest({ goal: snapshot.goalRevision, workspace: snapshot.workspaceRevision,
282
+ checks: remaining.map(item => item.content).sort() });
283
+ const reason = snapshot.deliveryContinuationDigest === progress ? 'delivery_no_progress'
284
+ : snapshot.repairs >= config.limits.maxRepairs || finalizationOnly(snapshot, config)
285
+ || toolRoom(snapshot, config) <= 0 || wallDeliveryOnly(snapshot, config) ? 'delivery_repair_budget_exhausted' : null;
286
+ if (reason) return transition(snapshot, { phase: 'paused', resumePhase: 'preparing_context', candidate: null, reason, outcome: null },
287
+ [{ kind: 'run.paused', payload: { reason } }]);
288
+ return transition(snapshot, { phase: 'preparing_context', candidate: null, preparedContext: null,
289
+ repairs: snapshot.repairs + 1, deliveryContinuationDigest: progress, messages: [...snapshot.messages,
290
+ { role: 'user', kind: 'verification_observation', content: canonical({ reason: 'delivery_todos_incomplete',
291
+ remaining: remaining.map(item => item.content),
292
+ instruction: 'The preceding draft was a progress report. Continue from the current workspace. Use committed tool results to identify and repair failures, run the remaining checks, and update the checklist only with observed results. If a concrete blocker requires the user, ask for the required input.' }) }] },
293
+ [{ kind: 'completion.continued', payload: { reason: 'delivery_todos_incomplete' } }]);
294
+ }
295
+ return finalizing(snapshot, 'unverified', 'verification_report_missing');
279
296
  }
280
297
  return prepareEffect(snapshot, 'verify', 'verifying', { candidate: objectValue(snapshot.candidate) });
281
298
  }
@@ -156,7 +156,8 @@ export function reduceCommand(snapshot: RunSnapshot, command: RunCommand, pendin
156
156
  ...(snapshot.reasoningStallRetry ? { reasoningStallRetry: false } : {}) } : {}),
157
157
  ...(bindings.configuration?.approvalOutcomePolicy === APPROVAL_OUTCOME_POLICY
158
158
  && ['approval_rejected', 'approval_cancelled', 'approval_unavailable'].includes(snapshot.reason ?? '') ? { reason: null } : {}),
159
- ...(['provider_unavailable', 'context_summary_unavailable', 'context_source_unavailable', 'child_paused']
159
+ ...(['provider_unavailable', 'context_summary_unavailable', 'context_source_unavailable', 'child_paused',
160
+ 'delivery_no_progress', 'delivery_repair_budget_exhausted']
160
161
  .includes(snapshot.reason ?? '') ? { reason: null } : {}) };
161
162
  break;
162
163
  case 'submit_interaction': {