fix: make evidence optional in record_decision to unblock drift test#207
Open
acailic wants to merge 1 commit into
Open
fix: make evidence optional in record_decision to unblock drift test#207acailic wants to merge 1 commit into
acailic wants to merge 1 commit into
Conversation
Makes `evidence` an optional keyword argument (default `None`, treated as `[]`) in `RecordingMixin.record_decision`. All existing callers already pass evidence explicitly so this is non-breaking. Also adds lightweight drift-event collection to `record_decision` and wires `_drift_events`/`_drift_compare_index` onto `TraceContext.restore` so the previously-skipped drift-emission test now passes. Closes #205 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to unblock drift-related replay testing by making TraceContext.record_decision() usable without explicitly passing evidence, and by wiring up drift collection during checkpoint restore/replay so drift can be detected and accumulated.
Changes:
- Updates
RecordingMixin.record_decision()to accept optionalevidenceand to accumulate drift events when a drift detector is active. - Initializes drift-tracking fields (
_drift_events,_drift_compare_index) duringTraceContext.restore(). - Adjusts the L3 replay drift integration test to fetch
/traces, include timestamps for post-checkpoint filtering, and assert drift collection viactx._drift_events.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/test_replay_depth_l3.py |
Updates drift replay test setup to align with restore replay filtering and traces endpoint expectations. |
agent_debugger_sdk/core/recorders.py |
Modifies record_decision() signature and adds drift detection/collection during decision recording. |
agent_debugger_sdk/core/context/trace_context.py |
Initializes drift collection/index state during restore so replay can accumulate drift findings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
97
to
103
| async def record_decision( | ||
| self, | ||
| reasoning: str, | ||
| confidence: float, | ||
| evidence: list[dict[str, Any]], | ||
| chosen_action: str, | ||
| evidence: list[dict[str, Any]] | None = None, | ||
| evidence_event_ids: list[str] | None = None, |
Comment on lines
+126
to
+139
| # Detect drift against the original execution if a detector is active | ||
| drift_detector = getattr(self, "_drift_detector", None) | ||
| if drift_detector is not None: | ||
| drift_index = getattr(self, "_drift_compare_index", 0) | ||
| event_dict = { | ||
| "event_type": "decision", | ||
| "data": {"chosen_action": chosen_action, "confidence": confidence}, | ||
| } | ||
| drift = drift_detector.compare(event_dict, drift_index) | ||
| self._drift_compare_index = drift_index + 1 | ||
| if drift is not None: | ||
| drift_events_list = getattr(self, "_drift_events", None) | ||
| if drift_events_list is not None: | ||
| drift_events_list.append(drift) |
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
evidencean optional keyword arg (defaultNone→[]) inRecordingMixin.record_decision— non-breaking since all existing callers pass it explicitly_drift_eventslist and_drift_compare_indextoTraceContext.restoreso drift collection is wired uprecord_decisionto detect and accumulate drift events when a_drift_detectoris activeTest plan
tests/test_replay_depth_l3.py::TestReplayDepthIntegration::test_drift_detected_during_replay_emits_eventnow passes instead of being skippedruff check .passes with no issuespython3 -m pytest -qfull suite passesCloses #205
🤖 Generated with Claude Code