feat: add correction flywheel (store, capture, parser, controller hooks)#116
Open
feat: add correction flywheel (store, capture, parser, controller hooks)#116
Conversation
Implements the correction flywheel MVP: - correction_store.py: JSON-file-based correction library with save/find (fuzzy string matching via SequenceMatcher)/load_all - correction_capture.py: Human correction capture using openadapt-capture Recorder (primary) with PIL screenshot fallback - correction_parser.py: VLM call to parse before/after screenshots into PlanStep dict (think/action/expect) - demo_controller.py: Added correction_store and enable_correction_capture params. On retry exhaustion: check correction store -> inject match, or capture human correction -> parse -> store -> advance - cli.py: Added --correction-library and --enable-correction-capture flags The loop: agent fails at step N -> correction store checked -> if match, inject corrected step -> if no match and capture enabled, human completes step -> Recorder captures -> VLM parses -> correction stored -> next run retrieves it. 17 tests added, all passing. 54 existing demo_controller tests unaffected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test was calling the real Recorder which may not have wait_for_ready in the installed version. Mock it to use the simple fallback path since this is a unit test. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the correction flywheel MVP — the core loop that makes OpenAdapt improve from production failures:
Agent fails at step N → correction store checked → if match, inject corrected step → if no match and capture enabled, human completes step → Recorder captures → VLM parses → correction stored → next run retrieves it.
New files (3)
correction_store.py(97 lines) — JSON-file-based correction library with save/find (fuzzySequenceMatcher)/load_allcorrection_capture.py(238 lines) — Human correction capture usingopenadapt-captureRecorder (primary path, full input events + action-gated screenshots) with PIL screenshot fallbackcorrection_parser.py(86 lines) — VLM call to parse before/after screenshots into PlanStep dict (think/action/expect)Modified files (2)
demo_controller.py(+147 lines) — Addedcorrection_storeandenable_correction_captureparams to DemoController andrun_with_controller. Three new methods:_try_stored_correction(),_try_capture_correction(),_capture_human_correction(). Hooks into retry-exhaustion path (before replan).benchmarks/cli.py(+18 lines) — Added--correction-libraryand--enable-correction-captureCLI flagsTests
test_correction_flywheel.py, all passingtest_demo_controller.pytests unaffected (71 total passing)Test plan
uv run pytest tests/test_correction_flywheel.py -v— 17/17 passinguv run pytest tests/test_demo_controller.py -v— 54/54 passing🤖 Generated with Claude Code