Improving by evolving context rather than optimizing weights.
1Beijing Jiaotong University
2University of Maryland, College Park
3UniPat.ai
4Suzhou Institute for Advanced Research, USTC
5University of British Columbia
6Department of Neurosurgery, Beijing Tiantan Hospital, Capital Medical University
* Equal contribution · Corresponding authors: Anchao Yang, Yutong Bai, Yan Wang
Understanding tens-of-minutes surgical videos requires long-horizon temporal reasoning: answering what happens before, after, or across stages of a procedure by grounding the question in visual evidence spread across time. Existing approaches handle this poorly. A one-shot vision–language model compresses the whole procedure to fit its context window and loses the detail a “before” or “after” question depends on, while video agents that train the model where to look are data-hungry and transfer poorly to out-of-domain surgery.
We build an agent harness that separates reasoning from perception and improves by evolving context rather than optimizing weights. A text-only orchestrator plans which evidence to gather and issues an auditable sequence of tool calls, while frozen vision–language sub-agents execute each call over the pixels — viewing, cropping, inspecting frames, and retrieving external knowledge. We further propose a gradient-free, reward-gated Heuristic Skill Distillation loop that mines the agent's own low-scoring traces and keeps a candidate skill only when it raises a validation reward, yielding reusable retrieval skills, notably directed re-look. Growing an external skill library rather than tuning weights, the loop adapts from only about one hundred labeled examples.
To evaluate this agent we introduce MedClawBench, a de-leaked, doctor-grounded benchmark of 1,123 questions over self-built long neurosurgery recordings and a held-out public lecture-video test split. Across both datasets and all four evaluation dimensions, our agent consistently outperforms one-shot VLMs and general video-agent frameworks, with the largest gains on the long, out-of-domain neurosurgery videos.
No weights are updated anywhere in the system. A text-only orchestrator (Opus-4.8) decides where to look but never sees a pixel; frozen vision sub-agents execute each call and return text. Competence accrues in an external skill library.
view_full_videoLocalizes where. A low-resolution pass over the whole procedure emits a dense timeline and a candidate window; a second pass re-watches that window at higher resolution and returns the tight sub-window.
crop_videoInspects what happens in a chosen range, re-read at crop resolution. This is the call that directed re-look aims at the adjacent window.
select_video_frameOne frame at one timestamp, described by an independent frame model — a cross-model check on a specific instrument or action.
crop_video_frameA normalized spatial region of a single frame, for disambiguating small or overlapping structures.
search_surgical_kbRetrieval over 1,039 PubMed-derived passages indexed in FAISS under cosine similarity. General surgical background only, with no benchmark answers.
Not a tool and not a rule we wrote. This is the entry the Heuristic Skill Distillation loop mined from the harness's own failed trajectories and then kept, because installing it raised the validation reward past the gate. It lives in an external skill library the orchestrator consults at inference, and it can be inspected, edited, or removed without touching a single weight.
The rule it learned: for a question about what precedes or follows a located event, the answer lies in the window adjacent to that event rather than inside it — so crop and re-read the following window for an “after” question, the preceding one for a “before” or preparation question, and ground the answer there.
Removing it costs more than removing any hand-designed component (−0.38 on the neurosurgery split), and it is exactly the failure mode the VTR partition is built to stress.
On a 60-question mining set the agent answers using the same tools it has at test time, then is shown the reference answer.
Operational (a different way of looking would have caught it), unreachable (no amount of looking recovers it), or already correct. Only the first carries an actionable lesson.
The agent writes the skill itself, and it must change how it looks, never what the answer should assert. Learning wording from an unreachable gold only teaches confident hallucination.
Install one candidate, re-answer a 40-question validation set, re-judge. Keep it only if the four-dimensional mean rises by more than δ = 0.05 and no single question drops by two points or more. A rejected skill leaves no trace.
Four dimensions, each scored 1–5 by a GPT-5.5 judge under the SurgVidLM rubric: correctness (CI), detail (DO), context (CU), temporal (TU). Reported separately for Visual Temporal Reasoning (VTR) and Visual Perception Reasoning (VPR).
| Method | Avg | Visual Temporal Reasoning | Visual Perception Reasoning | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Avg | CI | DO | CU | TU | Avg | CI | DO | CU | TU | ||
How today's strongest commercial models do on the same questions, ranked by the four-dimension mean. Every row is scored by the identical GPT-5.5 rubric, so the numbers are directly comparable.
| # | Model | Avg | VTR | VPR | CI | DO | CU | TU |
|---|
All on the neurosurgery split (259 questions), reporting the four-dimensional average.
Four-dimensional average, and the change relative to the full harness. † marks the component discovered by the distillation loop rather than designed by hand.
The same open-source model answering one-shot, then as the visual sub-agent inside our harness. The tick on each bar marks its one-shot score.
Quadratic weighted Cohen's κ against expert ratings: a neurosurgeon on 30 neurosurgery items, surgical experts on 70 SVU items.
| Dimension | Neurosurgery | SVU |
|---|---|---|
| CI — correctness | 0.71 | 0.87 |
| DO — detail | 0.66 | 0.86 |
| CU — context | 0.72 | 0.85 |
| TU — temporal | 0.74 | 0.86 |
| Overall | 0.72 | 0.86 |
Judge means track the experts almost exactly: 2.95 vs 2.94 on neurosurgery, 3.64 vs 3.65 on SVU.
Every question must survive a cascade certifying it can be answered only by watching the moment it targets: not from priors alone, not from a whole-procedure summary, not by listening to the narration, and — for neurosurgery — only if it matches the neurosurgeon's own interval annotation.
| Dataset | Video len. | ≥20 min | Temporal | De-leaked | Neuro. |
|---|---|---|---|---|---|
| EndoVis18-VQA | per-frame | — | ✗ | ✓ | ✗ |
| PitVQA | per-frame | — | ✗ | ✓ | ✓ |
| SurgViVQA | 8 frames | — | short | ✓ | ✗ |
| SVU-31K (test) | 13.9 min | 28% | partial | ✗ | ✗ |
| MedClawBench (ours) | 18.4 min | 41% | ✓ | ✓ | ✓ |
| neurosurgery split | 28.5 min | 71% | ✓ | ✓ | ✓ |
Video len.: median source-video duration. De-leaked: not answerable without watching, whether by explicit filtering or by the nature of the source.
The held-out test split of SVU-31K — 864 questions over 141 lecture videos, publicly
available. Each clip is stored under its SVU-31K id. Only test_data.zip
(157 GB, unpacking to about 148 GB) is needed; the training archives are not.
# only the test split is needed — the full repo is ~982 GB
huggingface-cli download gkw0010/SVU-31K test_data.zip \
--repo-type dataset --local-dir SVU-31K
unzip SVU-31K/test_data.zip -d SVU-31K # -> test_videos_part1/, test_videos_part2/
259 questions over 14 recordings from Beijing Tiantan Hospital, with golds grounded in a neurosurgeon's interval annotations. Because this is identifiable clinical footage, the videos are not yet public; they will be released through an application process. The questions and reference answers ship with the benchmark file.
The harness, the benchmark file, and the per-question scored answers behind every table live at github.com/fyyCS/medclaw-agent. We are finishing the final cleanup and will open the repository shortly.
# run the agent (lite backbone on SVU, flash on neurosurgery)
export SURG_VIDEO_MODEL=gemini-3.1-flash-lite
export SURG_SKILL_TOOLSET=1
python scripts/open_baseline_hermes.py --src <questions>.jsonl --out <answers>.jsonl
# score: four dimensions, 1-5, broken down by VTR / VPR
python surg_env/score_final.py --split neuro
python surg_env/score_final.py --split svu
@misc{fan2026medclawheuristicagentharness,
title={MedClaw: Heuristic Agent Harness for Long-Horizon Surgical Video Reasoning},
author={Yingying Fan and Penghui Du and Leyan Zhu and Runze He and Zimeng Wu and Yuxuan Zhang and Liang Chen and Jiahao Xie and Jiangtang Wang and Shuai Shao and Anchao Yang and Yutong Bai and Yan Wang},
year={2026},
eprint={2608.14015},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2608.14015},
}