Skip to content

[M2] Define shared failure injector interface#46

Merged
askmy-stack merged 1 commit into
mainfrom
m2-shared-failure-injector-interface
Jul 14, 2026
Merged

[M2] Define shared failure injector interface#46
askmy-stack merged 1 commit into
mainfrom
m2-shared-failure-injector-interface

Conversation

@askmy-stack

Copy link
Copy Markdown
Owner

Summary

  • Add a FailureInjector protocol (before_step / after_step / reset + triggered) in agentfailbench/failures/base.py so tool-drift, memory, planning, retrieval, data, and communication suites can share one lifecycle contract.
  • Add FailureInjectorRegistry for registering named injectors and dispatching hooks to all of them (registration/dispatch).
  • Add SemanticDriftInjectorAdapter, adapting the existing SemanticDriftInjector to the new protocol without changing its behavior.
  • Wire agentfailbench/runners/episode.py through the registry instead of calling SemanticDriftInjector directly.

Scope

  • before_step / after_step / reset protocol ✅
  • Wired through runners/episode.py

Acceptance criteria

  • Interface + adapter for existing SemanticDriftInjector
  • Tests for registration/dispatch

Fixes #12

Test plan

  • make ci (ruff check, ruff format --check, mypy, pytest) passes locally: 19 tests pass, 0 mypy errors.
  • New tests/unit/test_failure_injector.py covers: protocol conformance (isinstance checks), duplicate-registration rejection, get/list_names, dispatch of before_step/after_step/reset to multiple injectors, any_triggered, and adapter delegation to the wrapped SemanticDriftInjector.
  • Existing integration test (tests/integration/test_vertical_slice.py) still passes unchanged, confirming the episode runner's external behavior is preserved.

Made with Cursor

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>
@askmy-stack
askmy-stack merged commit 3a063e7 into main Jul 14, 2026
2 checks passed
@askmy-stack
askmy-stack deleted the m2-shared-failure-injector-interface branch July 14, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[M2] Define shared failure injector interface

1 participant