Repository navigation
Rubric Grader & Structured Output Validation for Local / Open-Weights Models #5746
Replies: 4 comments
|
The recovery boundary should be inside A robust sequence is:
The model adapter should still advertise the strategy it actually supports: use tool-based structured output for local models with reliable tool calling, and JSON/text parsing otherwise. But the rubric layer owns the semantic fallback because it knows whether failure should mean retry, I would avoid silently coercing |
|
I think this is a real weak spot with local models rather than something wrong with your setup. Looking at the current I’d probably keep the recovery inside the grader/rubric layer, but make it bounded: on a validation error, retry once with the actual Pydantic error + schema. If the model returned JSON in plain text, try parsing and validating that before giving up. I would avoid automatically converting things like There’s also #5030 discussing reliability hooks/retries around |
|
I’d separate recoverable formatting failures from actual schema/semantic failures. For example, JSON returned in That distinction could also make failures easier to observe/debug: So +1 to keeping recovery close to |
|
Because this Discussion predates the current The sync/async matrix showed:
The main finding is that current ToolStrategy already recovers from repairable schema-validation failures. The remaining gap is different: when a model fails to use the expected structured-output mechanism, ToolStrategy can continue retrying for a long time. In an untouched-default probe I observed 64 grader responses before stopping the harness; this does not establish infinite execution. Measured failures preserved the parent answer and checkpoint, and I did not reproduce a caller crash. I also prototyped an external recovery layer using the existing
So I would currently keep this opt-in and application-owned, implemented as grader middleware using existing public hooks. I did not find a need for a new Live model adapters and graders with ordinary tools still need validation. If this boundary looks useful, I'm happy to turn the relevant cases into focused regression tests or a small public-API example before proposing any framework change. |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I've been doing extensive testing of deepagents (using dcode) with local open-weights models via Ollama/llama.cpp, utilizing models like qwen3.8-coder and llama3.x.
I am seeing high crash and session deadlock rates when running rubric self-evaluation loops (RubricMiddleware / /goal grading) on local setups.
The Problem: Brittle Structured Output Handshakes
In deepagents, the rubric grader depends on strict Pydantic parsing (GraderResponse). On local hardware, even advanced models frequently fail this handshake due to formatting anomalies. When a validation failure occurs, the entire agent session crashes with a StructuredOutputValidationError.
Here are the three most common failure modes I've observed:
Schema Mismatches / Bad Parameter Types: Local models frequently output valid JSON but mismatch the nested schemas Pydantic expects. For example, returning a simple list of strings instead of a list of criterion dictionaries:
Markdown Fences & Conversational Prose: Despite system instructions, local models often wrap their structured tool calls in markdown blocks or prefix them with conversational fillers (e.g. "Here is your JSON response..."), causing simple string parses to fail.
Missing Tool Trigger: The model responds with a clean JSON body in the text content but fails to trigger the response_format or native tool call metadata, causing structured_response to resolve to None.
Why This is Critical for Phase-Gate Middlewares?
If these grading loops are brittle, local model workflows become practically unusable because a single formatting hiccup crashes a long-running multi-turn agent run.
While trying to find if there's any best practice I've missed out to adopt in my local setup, I've implemented some local fallbacks which catch validation errors, extract JSON from raw message content and fall back to text-only mode calls if needed. At least I've resolved those crashes in my setup for the time being.
Other structured output libraries (like Pydantic AI and Instructor) handle this by implementing client-side "validation rescue" and text-fallback parsers rather than treating a validation error as a fatal crash.
Has anyone else encountered these rubric/grader validation crashes when running local models?
What is the preferred architectural pattern in deepagents to introduce this type of resilience (e.g., handling it inside RubricMiddleware, at the model resolution layer, or via self-correcting retry prompts)?
Id love to hear your thoughts and align on the best path forward!
All reactions