[M2] Define shared failure injector interface#46
Merged
Conversation
SemanticDriftInjector previously wired directly into runners/episode.py with no common contract for future suites (memory, planning, retrieval, data, communication). Add a FailureInjector protocol (before_step/ after_step/reset + triggered) and a FailureInjectorRegistry that registers named injectors and dispatches lifecycle hooks to all of them, then adapt SemanticDriftInjector to the protocol and wire the episode runner through the registry instead of the concrete class. Fixes #12 Co-authored-by: Cursor <cursoragent@cursor.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
FailureInjectorprotocol (before_step/after_step/reset+triggered) inagentfailbench/failures/base.pyso tool-drift, memory, planning, retrieval, data, and communication suites can share one lifecycle contract.FailureInjectorRegistryfor registering named injectors and dispatching hooks to all of them (registration/dispatch).SemanticDriftInjectorAdapter, adapting the existingSemanticDriftInjectorto the new protocol without changing its behavior.agentfailbench/runners/episode.pythrough the registry instead of callingSemanticDriftInjectordirectly.Scope
before_step/after_step/resetprotocol ✅runners/episode.py✅Acceptance criteria
Fixes #12
Test plan
make ci(ruff check, ruff format --check, mypy, pytest) passes locally: 19 tests pass, 0 mypy errors.tests/unit/test_failure_injector.pycovers: protocol conformance (isinstance checks), duplicate-registration rejection,get/list_names, dispatch ofbefore_step/after_step/resetto multiple injectors,any_triggered, and adapter delegation to the wrappedSemanticDriftInjector.tests/integration/test_vertical_slice.py) still passes unchanged, confirming the episode runner's external behavior is preserved.Made with Cursor