-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Problem
When Agent.harness(..., schema=...) is used and the provider fails before writing .agentfield_output.json (for example opencode run returning Session not found), the SDK currently returns a generic schema error:
Schema validation failed after parse and cosmetic repair attempts.
This hides the real provider failure and makes debugging look like a schema problem.
Reproduction
- Provider:
opencode - Schema mode enabled (
schema=...) - CWD:
/tmp/dvga - Provider exits with
Session not found - No
.agentfield_output.jsonis created
Observed result:
is_error=Trueparsed=Noneerror_message="Schema validation failed after parse and cosmetic repair attempts."
Expected result:
- Preserve provider error (e.g.
Session not found) and include missing output-file context.
Root Cause
HarnessRunner._handle_schema_output() always returns the generic schema-validation error when parse_and_validate() returns None, even if raw.is_error=True from the provider and the output file was never created.
Proposed Fix
In _handle_schema_output():
- If
raw.is_errorand schema parsing failed, return provider error details. - If output file is missing, append context like:
Output file was not created at {path}
This keeps the schema path for normal validation failures while preserving root-cause visibility for provider/runtime failures.