Skip to content

Add zslice variant: scientific + midplane segment-count subagent - #3

Closed
trisha-ant wants to merge 2 commits into
trisha/gently-zslice-harnessfrom
trisha/gently-zslice-variant
Closed

Add zslice variant: scientific + midplane segment-count subagent#3
trisha-ant wants to merge 2 commits into
trisha/gently-zslice-harnessfrom
trisha/gently-zslice-variant

Conversation

@trisha-ant

Copy link
Copy Markdown
Owner

Stacked on #2 (which is stacked on #1).

Why

The fold-stage accuracy gap (1.5fold ~59%, 2fold ~70%) is the primary bottleneck for autonomous microscopy decisions. When a biologist can't tell the stage from a projection, they scroll z-slices and count body-segment cross-sections at the midplane: 1–2 profiles → 1.5fold, 2 separated → 2fold, 3+ crossing → pretzel. This variant does the same.

What

perception/zslice.py (118 lines), registered as zslice:

  1. Run perceive_scientific on the three-view projection.
  2. If primary's stage ∈ {1.5fold, 2fold, pretzel}, send midplane_b64 to a subagent that counts discrete body-segment cross-sections in the single optical slice.
  3. Map ≤1 → 1.5fold, 2 → 2fold, ≥3 → pretzel; override the primary.
  4. Record the override in reasoning and set verification_triggered=True, phase_count=2.
  5. Fall back to primary on parse failure (still marked triggered).

Trigger is the simplest baseline (primary ∈ fold stages). It deliberately excludes comma — segment count=1 is ambiguous between comma and 1.5fold, so a broader trigger would systematically push comma frames forward. The subagent only ever moves between fold stages, never into or out of them.

Verification

  • _accepted_optional_kwargs(zslice){'midplane_b64'}; scientificset() (runner correctly routes the slice only to zslice).
  • _segment_count_to_stage: 0→1.5fold, 1→1.5fold, 2→2fold, 3→pretzel, 5→pretzel.
  • _parse_segment_count handles int, "3 segments", "two"→None, garbage→None, missing key→None, code-fenced JSON.
  • Mocked perceive_zslice logic: passthrough on comma / no-midplane; override 2fold→pretzel on count=3 with (overrode 2fold) in reasoning; agreement still sets phase_count=2; parse-fail falls back to primary with verification_triggered=True.
  • Edge cases: negative count, empty history, 4-arg call all degrade safely.
  • Pyright on perception/zslice.py + __init__.py: 0 errors, 0 warnings.
  • python run.py --help exits 0; 16 variants registered.

Next

Ablation: python run.py --variant scientific zslice --stages pretzel 2fold 1.5fold --force (~642 API calls, ~6 min) — not run in this PR.

…old stages

Max-intensity projections fuse overlapping body segments, which is the
main reason 1.5fold/2fold/pretzel are hard to tell apart. This variant
runs the scientific classifier, and when that lands on a fold stage it
sends the midplane z-slice to a subagent that counts discrete
body-segment cross-sections (≤1 → 1.5fold, 2 → 2fold, ≥3 → pretzel)
and overrides.

Trigger is deliberately the simplest baseline (primary ∈ fold stages)
so the subagent only ever moves between fold stages, never into or out
of them — count=1 is ambiguous between comma and 1.5fold, so triggering
on comma would systematically push comma frames forward.

Override is recorded in reasoning ("(overrode 2fold)") and in
verification_triggered/phase_count for auditability.
…stages

Midplane slice rarely shows >=3 separable cross-sections on pretzel embryos
(body folds sit at different z-depths), so the segment-counting subagent
systematically downgrades correct pretzel calls to 2fold/1.5fold.

Per-stage vs scientific (n=233):
  1.5fold: 51.2% (-14.7)
  2fold:   59.3% (-1.7)
  pretzel:  6.8% (-81.2)
  adjacent: 89.3% (-10.3)
@trisha-ant

Copy link
Copy Markdown
Owner Author

Subsumed into #5 — all commits are in that branch and the retrospective there covers this variant.

@trisha-ant trisha-ant closed this Apr 28, 2026
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.

1 participant