Skip to content

workflow: StructuredOutput validator rejects weak-model outputs; needs lenient type coercion #282

Description

@ericleepi314

Source: PR #266 "Known follow-ups":

Type strictness: weak models (glm) return JSON types as strings ("42", an array as a string). Strict schema validation rejects these even after retries — needs lenient coercion in the StructuredOutput validator.

Impact: Workflow agent(..., {schema}) calls against weaker providers burn all schema-repair retries on type mismatches that are trivially coercible ("42"42, "true"true, JSON-encoded-string arrays → arrays), then fail the stage. This makes the workflow engine effectively Anthropic/OpenAI-only for structured stages.

Fix sketch: Before strict validation, run a lenient pre-pass keyed on the schema: coerce numeric/boolean strings where the schema expects number/integer/boolean, and json.loads string values where the schema expects array/object. Only fall back to the schema-repair retry loop if coercion still fails. Add fixtures from real glm outputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions