@goodandready/dsh-agent-loop-guard 0.2.25 → 0.2.26

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
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.26] - 2026-10-20
4
+
5
+ ### Fixed
6
+ - **Tools Result Payload Forwarding (#125, gh-1)**: Fixed tool outcome tracking in `lib/index.js` where `tools/result` event listener only captured the first argument (`execution`), losing the actual result payload passed as the second argument (`result`) by the DSH runtime (`dsh-tools`). Updated `tools/result` to capture `(execution, result)` and forward `{ ...execution, result }` to `state.recordResult()`. Updated `outcomeFromExecution` and `recordResult` in `lib/guard-state.js` to accept `maybeResult` and extract result payload, properly recognizing successful tool executions as productive progress (`productive: true`), advancing `progressEpoch`, and clearing `exactGroups`. Resolves false-positive `LOOP_GUARD_DUPLICATE` blocks on legitimate retries and eliminates catastrophic lockouts into `answerOnly` mode.
7
+
3
8
  ## [0.2.25] - 2026-10-19
4
9
 
5
10
  ### Fixed
@@ -155,20 +155,30 @@ function hasOwn(object, key) {
155
155
  return object !== null && typeof object === 'object' && Object.prototype.hasOwnProperty.call(object, key);
156
156
  }
157
157
 
158
- function outcomeFromExecution(execution) {
158
+ function outcomeFromExecution(execution, maybeResult = undefined) {
159
+ const result = maybeResult !== undefined ? maybeResult : execution?.result;
159
160
  const data = execution?.data;
160
- const hasResult = hasOwn(execution, 'result') || hasOwn(execution, 'output')
161
- || hasOwn(data, 'result') || hasOwn(data, 'output') || hasOwn(execution, 'error');
161
+ const hasResult = result !== undefined
162
+ || hasOwn(execution, 'result')
163
+ || hasOwn(execution, 'output')
164
+ || hasOwn(data, 'result')
165
+ || hasOwn(data, 'output')
166
+ || hasOwn(execution, 'error')
167
+ || hasOwn(execution, 'content')
168
+ || hasOwn(execution, 'isError');
162
169
  if (!hasResult) return { known: false, successful: false, resultFingerprint: '<unknown>', progressToken: '<unknown>' };
163
- const value = execution?.result ?? execution?.output ?? data?.result ?? data?.output
170
+ const value = result ?? execution?.output ?? data?.result ?? data?.output
164
171
  ?? (hasOwn(execution, 'error') ? { error: execution.error } : undefined);
165
172
  const failed = (execution?.error != null && execution?.error !== false)
173
+ || execution?.isError === true
166
174
  || value?.isError === true
167
175
  || value?.success === false
168
176
  || value?.ok === false
169
177
  || (value?.error != null && value?.error !== false);
170
178
  const explicitProgress = execution?.progressToken ?? execution?.progress ?? execution?.stateVersion
171
- ?? data?.progressToken ?? data?.progress ?? data?.stateVersion;
179
+ ?? data?.progressToken ?? data?.progress ?? data?.stateVersion
180
+ ?? value?.progressToken ?? value?.progress ?? value?.stateVersion
181
+ ?? value?.meta?.progressToken;
172
182
  return {
173
183
  known: true,
174
184
  successful: !failed,
@@ -515,7 +525,7 @@ export class LoopGuardState {
515
525
  }
516
526
  }
517
527
 
518
- recordResult(agent, execution = {}) {
528
+ recordResult(agent, execution = {}, maybeResult = undefined) {
519
529
  const state = this.stateFor(agent);
520
530
  const call = this.findCall(state, execution.callId);
521
531
  if (call === undefined) return { known: false, productive: false };
@@ -524,7 +534,7 @@ export class LoopGuardState {
524
534
  this.decrementReservations(state, call);
525
535
  return { known: false, productive: false };
526
536
  }
527
- const outcome = outcomeFromExecution(execution);
537
+ const outcome = outcomeFromExecution(execution, maybeResult);
528
538
  call.pending = false;
529
539
  call.committed = true;
530
540
  call.resultSeen = true;
package/lib/index.js CHANGED
@@ -302,8 +302,9 @@ export function apply(ctx, config = {}) {
302
302
  return next();
303
303
  });
304
304
 
305
- ctx.on('tools/result', (execution) => {
306
- state.recordResult(execution.agent, execution);
305
+ ctx.on('tools/result', (execution, result) => {
306
+ const payload = result !== undefined ? { ...execution, result } : execution;
307
+ state.recordResult(execution?.agent, payload, result);
307
308
  });
308
309
 
309
310
  ctx.on('session/event', (session, event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-agent-loop-guard",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "description": "Fail-closed runtime tool-call loop guard for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",