Problem
After each tool-use cycle, pycodeloop does not automatically verify outcomes. The agent writes code, marks the task done, and stops — even if tests are broken or lint fails. The human must manually run verification commands to discover regressions.
This is the core harness mechanism identified in "Code as Agent Harness" (arXiv 2605.18747): agent loops must close the write→execute→verify→re-plan cycle automatically.
Context
The harness pattern:
- Captures a lint/test baseline before the agent runs
- After each agent attempt, runs lint + test commands
- If they fail, calls
Canonicalise() to build a structured follow-up prompt with labelled sections: # Previous attempt failed, regression block, lint failures, test failures
- Retries up to
max_attempts (default 3)
Expected behavior
CodeLoop gains a verify_loop() method:
result = await codeloop.verify_loop(
prompt="Refactor the auth module",
lint_cmd="ruff check .",
test_cmd="pytest tests/",
max_attempts=3,
)
Internally:
- Capture baseline
(lint_ok, test_ok) before first attempt
- Run agent
- Run lint + test after each turn
- If verification fails, inject typed failure block into next prompt
- If baseline was green and result is red → flag regression explicitly
Suggested implementation
- Add
VerifyLoop class in pycodeloop/core/verify.py
- Add
canonicalise(lint_output, test_output, baseline) -> str pure function
- Add
verify_loop(prompt, lint_cmd, test_cmd, max_attempts=3) to CodeLoop
- Wire into JSONL trace: record
verify_attempt, verify_result, regression_detected events
References
- "Code as Agent Harness" — arXiv 2605.18747, Section 3.2 (Feedback-driven control)
Problem
After each tool-use cycle, pycodeloop does not automatically verify outcomes. The agent writes code, marks the task done, and stops — even if tests are broken or lint fails. The human must manually run verification commands to discover regressions.
This is the core harness mechanism identified in "Code as Agent Harness" (arXiv 2605.18747): agent loops must close the write→execute→verify→re-plan cycle automatically.
Context
The harness pattern:
Canonicalise()to build a structured follow-up prompt with labelled sections:# Previous attempt failed, regression block, lint failures, test failuresmax_attempts(default 3)Expected behavior
CodeLoopgains averify_loop()method:Internally:
(lint_ok, test_ok)before first attemptSuggested implementation
VerifyLoopclass inpycodeloop/core/verify.pycanonicalise(lint_output, test_output, baseline) -> strpure functionverify_loop(prompt, lint_cmd, test_cmd, max_attempts=3)toCodeLoopverify_attempt,verify_result,regression_detectedeventsReferences