@goodandready/dsh-agent-loop-guard 0.2.6 → 0.2.8
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/README.md +29 -1
- package/README.ru.md +28 -0
- package/README.zh.md +28 -0
- package/docs/design/DESIGN.md +25 -15
- package/lib/client.js +288 -51
- package/lib/guard-state.js +8 -10
- package/lib/index.js +63 -54
- package/lib/plugin-updater.js +20 -1
- package/package.json +1 -1
- package/docs/README.ru.md +0 -209
- package/docs/README.zh.md +0 -207
- package/docs/architecture/baseline.md +0 -37
- package/docs/research/reuse-first.md +0 -17
- package/docs/testing/test-plan.md +0 -21
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Architecture baseline
|
|
2
|
-
|
|
3
|
-
The plugin owns in-memory guard state only. Agent pre-step records turn and stop
|
|
4
|
-
mode. The documented DSH tools.guard hook synchronously evaluates each tool
|
|
5
|
-
attempt and returns either allow or a denial reason. Each accepted call enters a
|
|
6
|
-
progress ledger with a full argument fingerprint, a normalized repeat
|
|
7
|
-
fingerprint, and a pending/committed lifecycle. tools/result records the result
|
|
8
|
-
fingerprint and optional progress token. A successful change from the last
|
|
9
|
-
successful evidence advances a progress epoch, clears no-progress repeat
|
|
10
|
-
groups, and resets contextual budgets. Failed or unknown results leave the
|
|
11
|
-
no-progress counters intact.
|
|
12
|
-
|
|
13
|
-
The independent assistant-output branch subscribes to DSH session/event. It
|
|
14
|
-
tracks assistant/chunk text-delta events and assistant/message final content by
|
|
15
|
-
session. The final-message path accepts only Array.isArray(message.content)
|
|
16
|
-
text blocks and deduplicates messages already seen in the stream. After the
|
|
17
|
-
configured number of identical complete normalized lines, and only when no tool
|
|
18
|
-
call is active, it calls the public agent.cancel API with keepInbox: false.
|
|
19
|
-
The streak survives block, step, and turn boundaries and latches until a new
|
|
20
|
-
user message; tool calls reset the streak, and session-disposed events dispose
|
|
21
|
-
the in-memory state.
|
|
22
|
-
|
|
23
|
-
user message -> pre-step records turn -> model tool call -> tools.guard -> normalized DSH tool result -> model text response
|
|
24
|
-
assistant/chunk or assistant/message -> output state -> repeated-line threshold -> agent.cancel(keepInbox: false)
|
|
25
|
-
|
|
26
|
-
No DSH core, session log, client plugin, database, or external service changes.
|
|
27
|
-
|
|
28
|
-
Ordinary loop-prone tools consume maxToolAttemptsPerTurn. Explicit progress/state
|
|
29
|
-
tools (default todo_write) use a separate finite maxProgressToolCallsPerTurn
|
|
30
|
-
budget, so required checklist writes remain available after ordinary research
|
|
31
|
-
reaches its cap without creating an unlimited escape from the guard. Exact and
|
|
32
|
-
normalized-repeat checks run before either budget and apply to both classes.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## Assistant output loop detection
|
|
36
|
-
|
|
37
|
-
The host-only guard keeps two independent bounded detectors. The existing detector counts consecutive normalized complete lines. The multi-line detector fingerprints each completed assistant block (at block-end or final assistant message), keeps the count across step and turn boundaries, and trips only after the configured number of identical blocks without an intervening user message or tool call. A streamed block and its final message are counted once.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Reuse-first research
|
|
2
|
-
|
|
3
|
-
Reviewed installed DSH components.
|
|
4
|
-
|
|
5
|
-
- dsh-repeat-tool-reminder warns about repeat chains but does not enforce a bound.
|
|
6
|
-
- dsh-approval-gate uses public tools.guard and demonstrates a fail-closed denial before tool execution.
|
|
7
|
-
- agent/pre-step can reject a whole step, but DSH ends that turn as blocked and gives no model text response.
|
|
8
|
-
|
|
9
|
-
GitHub search found no reusable external DSH anti-loop bundle on 2026-08-19. This project therefore adapts the documented DSH guard pattern with a small deterministic state module.
|
|
10
|
-
|
|
11
|
-
The official DSH documentation describes plugins as the extension boundary and
|
|
12
|
-
the Cordis primer documents session event handling and agent lifecycle APIs.
|
|
13
|
-
The closest reusable external implementation found was opencode-auto-resume,
|
|
14
|
-
which detects repeated model output in an OpenCode-specific runtime; it cannot
|
|
15
|
-
be installed as a DSH bundle. This plugin therefore uses the documented DSH
|
|
16
|
-
session/event and agents.get(...).cancel(..., { keepInbox: true }) APIs rather
|
|
17
|
-
than patching DSH core.
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Test plan
|
|
2
|
-
|
|
3
|
-
Unit coverage verifies canonical and normalized fingerprints, result/state
|
|
4
|
-
progress epochs, productive same-argument iterations, unchanged-result
|
|
5
|
-
no-progress loops, read/edit retries, contextual aggregate and progress
|
|
6
|
-
budgets, distinct Gitea/curl endpoints, stop recovery on the next turn,
|
|
7
|
-
redacted structured violation logs, failed-result handling, explicit progress
|
|
8
|
-
tokens, malformed non-array user content, and turn reset.
|
|
9
|
-
|
|
10
|
-
Separate assistant-output coverage verifies whitespace normalization, five-line
|
|
11
|
-
threshold behavior, split streaming chunks, cross-block/step/turn persistence,
|
|
12
|
-
assistant/message fallback with malformed-content safety, deduplication,
|
|
13
|
-
tool-call suppression, user-message reset, configurable thresholds, multi-line
|
|
14
|
-
block normalization, block repetition, and stream/final-message deduplication. The
|
|
15
|
-
fixture is derived from the observed reinstall narration loop.
|
|
16
|
-
|
|
17
|
-
Syntax checks validate ESM source files. Runtime smoke tests install the bundle
|
|
18
|
-
in both the container and host/test profiles, replay productive and
|
|
19
|
-
no-progress tool-result sequences through the public tools.guard lifecycle,
|
|
20
|
-
and verify one structured denial plus an answer-only stop path. Assistant
|
|
21
|
-
output smoke verifies one cancellation with keepInbox:false.
|