Skip to content

fix: StateValidatorAgent graceful error handling instead of throwing#134

Open
pzysvip99999 wants to merge 2 commits intoNarcooo:masterfrom
pzysvip99999:fix/state-validator-agent-error-handling
Open

fix: StateValidatorAgent graceful error handling instead of throwing#134
pzysvip99999 wants to merge 2 commits intoNarcooo:masterfrom
pzysvip99999:fix/state-validator-agent-error-handling

Conversation

@pzysvip99999
Copy link
Copy Markdown

Fix: StateValidatorAgent graceful error handling

Problem

When the LLM (Phase 3 Auditor) outputs malformed JSON during the continuity validation step, StateValidatorAgent.parseResult() throws Error: "State validator returned invalid JSON". Similarly, if schema validation inside parseResult() fails, the error propagates up and crashes the pipeline.

The existing try/catch in validate() was also re-throwing, which means any LLM error during validation would abort the entire write pipeline.

Fix

Two changes in packages/core/src/agents/state-validator.ts:

  1. validate() catch block: Return { warnings: [...], passed: true } instead of re-throwing. The pipeline continues with a logged warning.

  2. parseResult() catch block: Return { warnings: [...], passed: true } instead of re-throwing the error. Schema validation failures become warnings, not crashes.

Together with PRs #132 (outer try-catch on validateRuntimeState) and #133 (sanitizeJSON for LLM output), this ensures the write pipeline is resilient to LLM-generated JSON malformed output at every layer.

OpenClaw Bot added 2 commits April 1, 2026 00:23
…ors from crashing the pipeline

The state validator was throwing an uncaught exception when the LLM output
contains invalid JSON characters (e.g. control chars, unescaped sequences),
causing the entire write pipeline to crash with 'State validator returned
invalid JSON'. This wraps the entire function in a try-catch so that any
such errors are returned as a validation issue rather than crashing.
…errors

Instead of throwing, catch blocks in validate() and parseResult() now
return { warnings: [...], passed: true } so the pipeline continues
without crashing when the LLM outputs malformed JSON or schema
validation fails mid-flight.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant