Skip to content

fix(generation): strip reasoning blocks before JSON parsing#750

Open
yipwingtim wants to merge 1 commit into
THU-MAIC:mainfrom
yipwingtim:upstream/fix-json-repair-llm-output
Open

fix(generation): strip reasoning blocks before JSON parsing#750
yipwingtim wants to merge 1 commit into
THU-MAIC:mainfrom
yipwingtim:upstream/fix-json-repair-llm-output

Conversation

@yipwingtim

Copy link
Copy Markdown

Summary

Strip model reasoning blocks before parsing JSON responses.

Some reasoning models may wrap intermediate thoughts in <think>...</think> before emitting the final
JSON. This can prevent otherwise valid JSON extraction and parsing.

Changes

  • Remove <think>...</think> blocks before JSON extraction.
  • Apply all existing parsing strategies to the cleaned response.
  • Log parse failure snippets from the cleaned response so diagnostics match the parser input.

Verification

  • pnpm lint passes locally with existing warnings.
  • pnpm exec tsc --noEmit was attempted locally, but the current working tree has stale .next generated type references and unresolved workspace package types unrelated to this one-file change.

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