Skip to content

fix(chat): preserve literal reasoning markers in answers - #1066

Merged
dovvnloading merged 1 commit into
mainfrom
agent/preserve-literal-reasoning-markers
Nov 25, 2026
Merged

dovvnloading merged 1 commit into
mainfrom
agent/preserve-literal-reasoning-markers

Conversation

@dovvnloading

Copy link
Copy Markdown
Owner

Summary

Fixes #1047.

Reasoning parsing previously searched the entire reply for think/fallback/Harmony markers, which could strip literal protocol examples from the final answer and misclassify them as reasoning.

  • Consume only contiguous leading reasoning envelopes; preserve deduplication of actual reasoning.
  • Recognize the Harmony final-answer boundary and strip only leading Harmony tokens.
  • Limit the ambiguous closing-only fallback to a standalone closing line after a nonempty, non-code-like prefix; never reapply it after an explicit envelope.
  • Add 33 parameterized regression cases covering XML code nodes, inline/fenced examples, literal closing tags, fallback and Harmony formats, multiple leading envelopes, and reasoning-only provider retry behavior.

Validation

  • Isolated regression harness using the repository parser and provider regex constants: before fix, 27 failed / 6 passed; after fix, 33 passed.
  • Python compilation of the isolated modules and tests passed.
  • Committed blob hashes match the locally tested production and test files.

Full repository tests have not been run: cloning GitHub from the execution environment was unavailable. The local harness used a minimal provider shim rather than the full provider runtime. Keeping this PR in draft for CI/full-suite review.

Compatibility note

Unmarked closing-only reasoning is inherently ambiguous. The more conservative fallback deliberately leaves inline or code-like closing-tag sequences visible instead of guessing that they are reasoning. Explicit leading envelopes and Harmony boundaries remain supported.

Restrict reasoning extraction to leading envelopes and preserve code examples.
Add regression coverage for #1047.

@dovvnloading dovvnloading left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed both changed files against #1047, including the provider regex definitions, the current main response parser, and regression coverage. No blocking findings in the reviewed diff: matching only contiguous leading envelopes preserves fenced/inline protocol examples, the Harmony final boundary prevents reparsing visible content, and the conservative closing-only heuristic trades ambiguous inline delimiters for preservation of the answer. The new tests cover genuine reasoning, deduplication, retry behavior, and code-node extraction. Main's intervening changes do not edit either changed file; its updated fenced-code parser is compatible with the new XML cases. CI build and POSIX jobs have passed; Windows/full pytest and frontend checks are still running. The nightly-only Playwright job is skipped as expected. I could not clone the repository locally (GitHub DNS unavailable), so I have not independently executed the full suite. This is a review comment rather than self-approval (the authenticated account is the PR author). Ready for squash auto-merge only after all four required CI checks pass; no admin bypass or gate changes.

@dovvnloading
dovvnloading marked this pull request as ready for review November 25, 2026 10:32
@dovvnloading
dovvnloading enabled auto-merge (squash) November 25, 2026 10:32
@dovvnloading
dovvnloading merged commit 6b86cbc into main Nov 25, 2026
5 checks passed
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.

bug(chat): literal think tags in code examples are stripped from the actual answer

1 participant