Structured Tool-Call Recovery and Execution Middleware for Open-Weight Coding Agents
Add structured decoding and automated execution-recovery middleware to coding agent harnesses so open-weight models stop failing silently from malformed tool calls.
Time
Compute level
Resources
What the paper used
Prerequisites
Scope
The Gap
In Section 3.3, open-weight coding models evaluated under OpenCode exhibit a steep rank correlation (Spearman rho = 0.93) between score and number of videos delivered: four models (Gemma 3 27B/12B, Llama 3.3 70B, Magistral Small) call zero tools across 500 attempts, while Qwen3-32B and Llama 4 Maverick terminate prematurely with fewer than three calls.
“Because an instance without a video scores 0, delivery failure is the primary driver of the lowest scores.”
Limitation
Standard terminal agent harnesses discard prose responses and malformed tool syntax, causing open-weight models to score zero due to delivery failure even when they can reason about the visual problem.
Proposed Solution
Build a resilient harness adapter combining constrained grammar/JSON-schema decoding for tool invocations, automatic extraction and sandboxed execution of markdown Python blocks when a model responds in prose, automated error-traceback re-prompting on premature exits, and rejection of non-existent sub-agent delegations.
Why This Matters
Eliminating mechanical delivery failures should decouple tool-formatting compliance from true visual-reasoning capability, recovering substantial benchmark performance from existing open-weight models at minimal engineering cost.
How to Get Started
How to test it: Test whether execution-recovery middleware raises video delivery rate from 0%-5% to >90% and improves overall VBVR-Pro-Bench scores on Gemma 3 27B, Llama 3.3 70B, Qwen3-32B, and Llama 4 Maverick; stop if recovered videos still yield near-zero content scores.
- Clone the OpenCode harness and reproduce the zero-delivery and premature-termination failures on a 50-instance stratified sample using Qwen3-32B, Llama 4 Maverick, and Gemma 3 27B.
- Implement a response parser and guardrail loop that intercepts prose code blocks or invalid sub-agent calls, executes valid Python code in the sandbox, and returns stdout/stderr or missing-video reminders until `video.mp4` is written.
- Add constrained tool-call formatting or few-shot tool-use exemplars for models without native Bedrock tool-calling support.
- Benchmark video delivery rate and final VBVR-Pro-Bench content scores across all 500 instances against the unmodified OpenCode baseline.
Suggested by AI. Adapt it to your setup.
Has This Been Done?
Works such as Beyond Prompts: Measuring and Optimizing LLM Tool-Agent Harnesses and Agentic Harness Engineering explore harness engineering, tool use, and execution integrity for LLM agents. They leave open the specific combination of constrained grammar decoding, automatic markdown python block extraction, error-traceback re-prompting, and rejection policies tailored for open-weight coding agents.
- Beyond Prompts: Measuring and Optimizing LLM Tool-Agent Harnesses · 2026 · 6 citations
- Context-to-Execution Integrity for LLM Agents · 2026 · 15 citations
- Agentic Harness Engineering: Observability-Driven Automatic Evolution of Coding-Agent Harnesses · 2026 · 216 citations
We searched OpenAlex and arXiv for “open-weight LLM agent tool-call recovery execution harness” and “Structured Tool-Call Recovery and Execution Middleware for Open-Weight Coding Agents” and an AI compared the idea with the top 10 results. A small search can miss relevant work.
Source Paper
Solve Vision with Code: Coding Agents Are Stronger Visual Reasoners Than Video ModelsDezhi Luo, Fengyuan Yu, Haotian Zhang +11 more · 2026
This paper evaluates whether off-the-shelf coding agents outperform native video generation models on visual reasoning tasks when evaluated under identical inputs, output video format, and an unmodified deterministic evaluator on VBVR-Pro-Bench. By writing Python programs that render answer videos in a CPU sandbox, three closed-model coding agents achieve scores of 0.893 to 0.923, surpassing the best RL-trained video model (0.670) by over 0.22, while the strongest open-weight model (GLM-5) reaches 0.572.
Related Ideas
- Extending Verifiable Evaluation to Real-World Structured, Multi-Turn, and Multimodal WorkflowsInstruction-Following Evaluation for Large Language Models🟠Medium
- Robust Control via Constrained DecodingRecursive Language Models🟡Fairly easy
- Instruction-Controllable VLMs for Strict Formatting via Preference OptimizationStepping VLMs onto the Court: Benchmarking Spatial Intelligence in Sports🟢Easy
- Decoupled 4D Perception-to-Code Pipeline Using Geometric and Body Reconstruction PriorsVibePrevisBench: Evaluating Agentic Coding for 4D Scene Generation in Blender🔴Hard
- Syntax-Tree-Constrained Surgical Patching for Video Agent Edit LocalityVibeVideoAgent: Closing the Perceptual Loop for Code-Driven Video Generation🟡Fairly easy