Skip to content

Add minimum trial threshold to bias intervention - #160

Merged
micahwoodard merged 3 commits into
mainfrom
fix-174-min-trials-antibias
Aug 26, 2026
Merged

Add minimum trial threshold to bias intervention#160
micahwoodard merged 3 commits into
mainfrom
fix-174-min-trials-antibias

Conversation

@micahwoodard

@micahwoodard micahwoodard commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Add minimum trial threshold to bias interventions, regenerates all of the schemas, and updates and adds tests. Default is 100. Relevant file changes at src\aind_behavior_dynamic_foraging\task_logic\interventions\bias_intervention.py. Fixes #174

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an optional “minimum trial threshold” gate for anti-bias interventions so that corrections don’t trigger until enough trials have elapsed, then propagates the new field through schemas/generated code and updates tests accordingly.

Changes:

  • Add trial_threshold to BiasInterventionParameters and enforce it in are_antibias_conditions_met(...).
  • Pass session trial count into bias-intervention checks from the block-based trial generator.
  • Regenerate schemas / generated bindings and extend unit tests for the new threshold behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/aind_behavior_dynamic_foraging/task_logic/interventions/bias_intervention.py Adds trial_threshold parameter and gates intervention triggering based on n_trials.
src/aind_behavior_dynamic_foraging/task_logic/trial_generators/block_based_trial_generator.py Passes len(outcome_history) into are_antibias_conditions_met(...) to supply n_trials.
tests/test_interventions/test_bias_intervention.py Updates call sites to pass n_trials and adds explicit tests for trial_threshold.
tests/trial_generators/test_block_based_trial_generator.py Extends test helper to pass trial_threshold into parameters; updates some tests to override it.
src/Extensions/AindBehaviorDynamicForaging.Generated.cs Regenerated C# model includes TrialThreshold property and printing.
schema/aind_behavior_dynamic_foraging.json Regenerated JSON schema includes trial_threshold.
schema/uncoupled.json Regenerated example/config includes trial_threshold.
schema/uncoupled_baiting.json Regenerated example/config includes trial_threshold.
schema/coupled_baiting.json Regenerated example/config includes trial_threshold.
Suppressed comments (1)

src/aind_behavior_dynamic_foraging/task_logic/interventions/bias_intervention.py:81

  • Docstring references a non-existent parameter name (parameters.min_trials_for_bias_intervention). The actual field added is parameters.trial_threshold, so this documentation is misleading and will confuse future maintenance.
        Intervention is only considered once ``n_trials`` has reached
        ``parameters.min_trials_for_bias_intervention`` and
        ``trials_in_bias_intervention`` exceeds ``parameters.intervention_interval``.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/aind_behavior_dynamic_foraging/task_logic/interventions/bias_intervention.py Outdated
Comment thread src/Extensions/AindBehaviorDynamicForaging.Generated.cs Outdated
intervention_interval: int = 10,
total_offset: float = 0.0,
threshold: BiasThreshold = BiasThreshold(upper=0.7, lower=0.3),
trial_threshold: int = 100,

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

tests/trial_generators/test_block_based_trial_generator.py:77

  • The anti-bias generator test helper now defaults trial_threshold to 100, but these tests don't populate gen.outcome_history, so n_trials passed from len(self.outcome_history) is 0 and anti-bias interventions won't actually trigger. This can make assertions pass vacuously (e.g., is_auto_reward_right stays None). Consider defaulting this helper's trial_threshold to 0 (tests that specifically cover the threshold are already in tests/test_interventions/test_bias_intervention.py).
        trial_threshold: int = 100,

Comment thread src/aind_behavior_dynamic_foraging/task_logic/interventions/bias_intervention.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@micahwoodard
micahwoodard merged commit 2f17a65 into main Aug 26, 2026
@micahwoodard
micahwoodard deleted the fix-174-min-trials-antibias branch August 26, 2026 16:42
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.

3 participants