← Back to PRs

#6678: fix(agents): support thinking tags with attributes

by GHesericsu open 2026-02-01 23:06 View on GitHub →
agents
Updated regex patterns to match thinking tags with attributes: - Modified `THINKING_TAG_SCAN_RE` and related patterns to capture optional attributes - Changed from `\s*>` to `\b[^<>]*>` pattern ## AI Assistance Used Claude Code to: - Identify regex patterns that needed updating for thinking tags with attributes - Write regression test for Gemini-style attribute-bearing thinking tags Fully tested locally (build + tests pass). - [x] Mark as AI-assisted in the PR title or description - [x] Note the degree of testing (untested / lightly tested / fully tested) - [x] Include prompts or session logs if possible (super helpful!) - [x] Confirm you understand what the code does <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the embedded agent streaming logic to treat `<think>`/`<thinking>`/`<thought>`/`<antthinking>` tags as reasoning blocks even when the opening/closing tags include attributes (e.g. `<thinking reason="...">`). It does this by widening the regexes used to scan and strip thinking tags during streaming, and adds a regression test that simulates Gemini-style attribute-bearing thinking tags to ensure hidden reasoning is suppressed and only the visible answer is emitted. These changes fit into the existing embedded PI session subscription pipeline (`subscribeEmbeddedPiSession`) which already strips/segments reasoning and enforces final-tag handling while preserving inline-code spans; this PR makes the thinking-tag detection more robust for providers that emit attributes in their tag syntax. <h3>Confidence Score: 4/5</h3> - This PR is generally safe to merge, with one consistency bug around streaming extraction of attribute-bearing thinking tags. - The change is narrowly scoped (regex widening + a focused regression test) and aligns with existing thinking-tag stripping behavior. The main concern is `extractThinkingFromTaggedStream` still using the pre-change regex patterns, which can lead to inconsistent behavior for streaming providers that emit thinking tags with attributes before closure. - src/agents/pi-embedded-utils.ts (extractThinkingFromTaggedStream regexes) <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs