v2026.5.6 — Agent-loop Completion Inference + Auto-Compact Discipline
Agent-loop completion inference, auto-compact discipline, and publish workflow ordering fixes.
v2026.5.6 — Agent-Loop Completion Inference + Auto-Compact Discipline
Tag: `v2026.5.6` · Released: 2026-05-14 · npm: `npm install -g [email protected]`
Two behavioral upgrades that make iterative and long-running work survive context pressure and reach measurable completion without operator hand-holding. Plus a CI workflow ordering fix that closes the v2026.5.5 stable-publish regression mode.
TL;DR
# Install
npm install -g [email protected]
# Try the new completion inference (no --completion needed)
agent-loop "fix the failing auth tests"
# → derives `npm test` (or whatever the project actually uses) from
# CLAUDE.md, package.json scripts, CI config, .aiwg artifacts,
# confirms once, then iterates against the inferred gate
# CI-style auto-adopt
agent-loop "fix all type errors" --auto-criteria
# Force the old behavior (require explicit --completion)
agent-loop "task" --no-infer-completion
If you've ever had an agent stop mid-task to ask "should I keep working?": the new `auto-compact-continue` rule (HIGH, deployed via `aiwg-utils`) says the answer is always yes unless the task's measurable completion criteria are met or a real authorization gate has appeared. The rule codifies what to do instead: write a progress file at `.aiwg/working/<task>-progress.md`, let auto-compact run, recover from the durable substrate (activity log, progress file, git, AIWG memory, `CLAUDE.md`/`AGENTS.md`/`AIWG.md`).
If you run iterative loops without thinking too hard about completion criteria: the new `infer-completion-criteria` skill walks 5 evidence layers and proposes a measurable verification command grounded in your project's actual config — not a generic guess.
What's in the box
1. `infer-completion-criteria` skill
A new skill in the `agent-loop` addon (`agentic/code/addons/agent-loop/skills/infer-completion-criteria/`). Invoked automatically by `agent-loop`, `ralph` (legacy executor name), and `agent-loop-ext` when the user starts a loop without `--completion`.
The pipeline is a deterministic walk through five evidence layers, plus a synthesis step that validates against the `vague-discretion` rule:
| Layer | Source | What it contributes |
|---|---|---|
| 1 | Task verb in the user's request | Maps to a criterion class — test-pass, type-clean, regression-gate, coverage, lint-clean, build-pass, implement-feature |
| 2 | `CLAUDE.md` / `AGENTS.md` / `AIWG.md` Development section | The canonical commands the project's maintainers actually run |
| 3 | Package manifests (`package.json`, `Cargo.toml`, `pyproject.toml`, `go.mod`, `Gemfile`, `pom.xml`, `build.gradle`) | Discovered scripts and toolchain conventions |
| 4 | CI config (`.github/workflows/`, `.gitea/workflows/`, GitLab/CircleCI/Jenkins) | The team's actual "passes" definition — the gate enforced before merge |
| 5 | `.aiwg/` artifacts (test-strategy, related use cases by ID match, prior progress files) | Project-specific gates, including UC-XXX acceptance criteria when the task references a use case ID |
The synthesis step produces a structured YAML proposal:
proposed_completion:
criterion: "npm test passes AND npx tsc --noEmit exits 0"
verification_command: "npm test && npx tsc --noEmit"
rationale:
- "Task verb 'refactor' triggers regression gate (Layer 1)"
- "package.json scripts.test = 'jest --coverage' (Layer 3)"
- "CLAUDE.md Development section references both checks (Layer 2)"
- ".github/workflows/ci.yml runs both as required checks (Layer 4)"
confidence: high
alternatives_considered:
- criterion: "npm run lint exits 0"
rejected_because: "Lint is not in CI required checks for this repo"
max_iterations_suggestion: 10
needs_human_confirmation: false
The confirm-or-edit flow uses the platform's native interaction tool (`AskUserQuestion` on Claude Code, formatted text elsewhere per `native-ux-tools`). Headless / CI runs adopt high-confidence proposals automatically with `--auto-criteria`, or fail fast with the proposal printed as a diagnostic so the user can re-launch with `--completion` explicit.
The refusal case is named explicitly: if the task is genuinely vague ("make the code better") and no measurable criterion can be derived, the skill refuses and prints concrete rephrasing suggestions. A loop with no measurable gate runs forever or exits prematurely, which is the failure mode `vague-discretion` exists to prevent.
Edge cases the skill handles:
- Multi-language monorepos (workspace config detection)
- Projects with broken test suites (the criterion IS getting from red to green)
- Projects with no tests at all (surfaces this as a finding; the criterion becomes "tests exist for new code AND pass")
- Conflict between layers (prefer `CLAUDE.md` over CI over manifest)
- Multiple test commands (`test:unit` / `test:integration` / `test:e2e`) — picks based on task scope
- Use-case ID in the task → pulls acceptance criteria verbatim from `.aiwg/requirements/UC-XXX.md`
2. `auto-compact-continue` rule (HIGH)
A new rule deployed to every provider via `aiwg-utils` (core, autoInstall). The single load-bearing statement:
The answer to "should I keep working?" is always YES — until the task's stated completion criteria are met or the user has redirected. Context pressure is not a scope question. Long tool output is not a scope question. Crossing iteration N is not a scope question. The right response to all of them is: compact, checkpoint to durable storage, and continue.
Named exceptions:
1. Authorization gates (per `human-authorization` rule) — destructive or out-of-scope action discovered; ask about that action, not about continuation 2. Three-attempts-failed escalation (per `anti-laziness` Rule 6) — with full context 3. Explicit user redirect 4. Genuinely ambiguous new-directive classification (per `skill-discovery` Rule 0)
The rule then provides the operational pattern that makes "always continue" safe:
- Durable substrate table — what survives compaction (`CLAUDE.md` / `AGENTS.md` / `AIWG.md`, activity log, AIWG memory, progress file, git history, `.aiwg/working/`) vs what's at risk (raw tool outputs, exploratory reasoning, earlier turns)
- Progress file template — `.aiwg/working/<task-slug>-progress.md` with required sections: task contract, current status, completed steps, failed approaches (do not retry), open questions, state references. Per REF-909 (Anthropic), the "failed approaches" section is the single most underrated artifact — without it post-compaction agents re-discover known dead ends
- Trust auto-compact — let the platform run it; preserve state on disk before context fills, not after
- Compact Instructions block — a `## Compact Instructions` section in your `CLAUDE.md` / `AGENTS.md` / `AIWG.md` biases the summarizer toward preserving completion criteria, last successful step, failed approaches, authorization questions
- Aggressive in-session compression — REF-122 (Verma, 2026): passive prompting yields ~6% savings, aggressive every-10–15-tool-calls discipline yields ~22.7%. The rule prescribes the aggressive variant
- Recovery protocol after compaction — read progress file first, then recent activity log, then git status, reconcile, skip failed approaches, resume from "Next action"
Cross-references to every interacting rule (`vague-discretion`, `anti-laziness`, `human-authorization`, `instruction-comprehension`, `skill-discovery`, `activity-log`, `context-budget`, `subagent-scoping`, `context-bloat`).
The rule body landed in v2026.5.5's incident-fix commit (the rule file and the v2026.5.5 release work happened in the same overnight session); it's surfaced in this release because the user-facing impact is felt now that the agent-loop changes pair with it.
3. CI workflow ordering fix
`.gitea/workflows/npm-publish.yml` — the Build step now runs before Run tests, matching `ci.yml`. Several tests assert on `dist/` output (e.g. `test/unit/cli/validate-metadata-import.test.ts` asserts the import path resolves to `dist/src/plugin/metadata-validator.js` — regression test for #1001). The v2026.5.5 stable publish hit this exact ordering bug.
Inline comment in the workflow file cites the v2026.5.5 incident so future contributors understand the ordering constraint isn't accidental.
How to use the new completion inference
The default path — let inference run:
agent-loop "fix the failing auth tests"
# Output:
# Inferring completion criteria...
# Layer 1 verb: "fix tests" → test-pass class
# Layer 2 CLAUDE.md: "npm test" is the canonical test command
# Layer 3 package.json: scripts.test = "jest"
# Layer 4 CI: .github/workflows/ci.yml runs `npm test`
# Layer 5: no related use case found
#
# Proposed criterion: npm test passes (exit 0)
# Verification: `npm test`
# Confidence: high
#
# Proceed? [Y/n/edit]
Auto-adopt for CI / scripted use:
agent-loop "fix all TypeScript errors" --auto-criteria
Explicit-required (old behavior):
agent-loop "task" --no-infer-completion
# → fails fast with: "Error: --completion is required. To enable inference, omit --no-infer-completion."
With a use case ID — inference picks up acceptance criteria:
agent-loop "implement UC-AUTH-001"
# Output:
# Inferring completion criteria...
# Layer 5: found .aiwg/requirements/UC-AUTH-001-user-login.md
#
# Using acceptance criteria from UC-AUTH-001:
# - [ ] User can log in with valid email/password
# - [ ] Invalid credentials show clear error message
# - [ ] Account locks after 5 failed attempts
# - [ ] Login completes within 2 seconds
#
# Proposed criterion: All acceptance criteria from UC-AUTH-001 verified by tests,
# AND `npm test -- --testPathPattern=auth` passes
# Confidence: high (acceptance criteria are explicit)
Refusal case — vague task:
agent-loop "make the code better"
# Output:
# Cannot infer measurable criteria for this task.
#
# "Make the code better" is vague (per AIWG vague-discretion rule).
# A loop with no measurable gate runs forever or exits prematurely.
#
# Please supply --completion with a concrete check, e.g.:
# --completion "npm test passes AND npm run lint exits 0"
# --completion "all functions in src/utils/ have JSDoc"
# --completion "complexity score from eslint < 10 for all files"
#
# Or rephrase the task with a concrete intent:
# agent-loop "reduce cyclomatic complexity in src/utils/"
# agent-loop "add JSDoc to all exported functions in src/api/"
How `auto-compact-continue` changes behavior
In practical terms: agents that previously stopped to ask "should I keep working?" mid-task will now compact and continue against the same measurable gate, recording state to disk so the loop survives platform auto-compact.
The rule is deployed via `aiwg-utils` (core, autoInstall) — you don't need to do anything to get it. After `npm install -g [email protected]`, run `aiwg refresh` to redeploy the rule to your installed providers.
To opt into the strongest version of the discipline, add a `## Compact Instructions` section to your project's `CLAUDE.md` / `AGENTS.md` / `AIWG.md`. A minimum-viable block:
## Compact Instructions
When summarizing this conversation for compaction, preserve:
1. The current task's completion criteria verbatim.
2. The last successful step and any verification command that proved it.
3. Failed approaches and the reason each failed (do not let them be re-attempted).
4. References to `.aiwg/working/*-progress.md`, `.aiwg/activity.log`,
and any in-flight commits.
5. Pending authorization questions that were raised but not answered.
6. Open scope boundaries (what is in/out of scope for this task).
Discard:
- Exploratory reasoning traces leading to already-known conclusions.
- Tool outputs that were superseded by later, more authoritative reads.
- Greetings, status banners, and other non-load-bearing prose.
This block survives compaction because system-prompt-scope content (`CLAUDE.md` and equivalents) is what the auto-compact mechanism guarantees to keep.
Research foundation
Two new references added to the AIWG companion `research-papers` corpus:
- REF-909 — Anthropic Applied AI Team. Effective Harnesses for Long-Running Agents. Anthropic Engineering Blog, Nov 2025. link
- Initializer-agent / coding-agent pattern
- `claude-progress.txt` as the load-bearing artifact across context resets
- "Failed approaches" section as the single most underrated component
- Companion reference implementation at github.com/anthropics/cwc-long-running-agents
- REF-910 — Anthropic. Compaction. Claude API Documentation, 2026. link
- Auto-compact mechanics: triggers, summarization, continuation
- `## Compact Instructions` for biasing what survives
- What survives compaction vs what's at risk
- The v2.1.96 regression where system-prompt inflation collapsed the auto-compact budget — documents that the trigger threshold is sensitive to context costs the user doesn't control
Both refs are GRADE LOW (vendor documentation) but authoritative for Claude-specific patterns and reflect production experience.
The empirical basis for aggressive in-session compression discipline is REF-122 (Verma, Active Context Compression: Autonomous Memory Management in LLM Agents, arXiv:2501.09067, 2026) — already in corpus. Focus Agent on N=5 SWE-bench Lite instances using Claude Haiku 4.5: 22.7% token reduction with aggressive compression every 10–15 tool calls, vs 6% with passive prompting, identical accuracy.
Files of interest
| Path | Lines | Change |
|---|---|---|
| `agentic/code/addons/agent-loop/skills/infer-completion-criteria/SKILL.md` | new (~280) | The inference pipeline |
| `agentic/code/addons/aiwg-utils/rules/auto-compact-continue.md` | new (~250) | The HIGH rule |
| `agentic/code/addons/agent-loop/skills/agent-loop/SKILL.md` | modified | Delegates inference to the new skill |
| `agentic/code/addons/agent-loop/skills/ralph/SKILL.md` | modified | `--completion` optional + progress-file write |
| `agentic/code/addons/agent-loop/skills/agent-loop-ext/SKILL.md` | modified | Same for the external launcher |
| `agentic/code/addons/agent-loop/agents/ralph-verifier.md` | modified | Companion-skill section |
| `agentic/code/addons/agent-loop/manifest.json` | modified | Skill registration |
| `agentic/code/addons/aiwg-utils/manifest.json` | modified | Rule registration |
| `agentic/code/addons/aiwg-utils/rules/RULES-INDEX.md` | modified | New HIGH entry, count → 21 |
| `.gitea/workflows/npm-publish.yml` | modified | Build before tests |
What this doesn't do (yet)
The JS launcher at `tools/ralph-external/session-launcher.mjs` does not yet call `infer-completion-criteria` before spawning the external loop process. The skills above document the contract; the launcher integration is a follow-up that touches stable working code and deserves a dedicated change. The in-session `ralph` skill works as documented because it's an in-context Skill invocation, not a launcher subprocess.
If you depend on the external loop's automatic completion inference, pin to explicit `--completion` for now and watch for the follow-up.
Upgrade
npm install -g [email protected]
aiwg refresh # redeploy rules + agent-loop skill set
aiwg doctor # confirm clean state
No config changes required. The new behavior activates only when `--completion` is omitted from a loop invocation.
Links
- Tag: v2026.5.6 on Gitea
- Mirror: github.com/jmagly/aiwg
- npm: `npm install -g [email protected]`
- CHANGELOG entry: CHANGELOG.md
- New rule: auto-compact-continue.md
- New skill: infer-completion-criteria/SKILL.md