#6678: fix(agents): support thinking tags with attributes
agents
Cluster:
Model Reasoning Fixes
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
#17304: feat(gemini): robust handling for non-XML reasoning headers (`Think...
by YoshiaKefasu · 2026-02-15
81.1%
#20050: fix: Telegram polling regression and thinking blocks corruption (AI...
by Vaibhavee89 · 2026-02-18
78.6%
#17455: fix: strip content before orphan closing think tags
by jwt625 · 2026-02-15
78.2%
#10097: fix: add empty thinking blocks to tool call messages when thinking is…
by cyxer000 · 2026-02-06
78.1%
#13235: feat: stream reasoning_content via /v1/chat/completions SSE
by mode80 · 2026-02-10
77.5%
#23462: fix: extract thinking blocks as fallback in extractTextFromChatContent
by nszhsl · 2026-02-22
76.5%
#22797: Feat/auto thinking mode
by jrthib · 2026-02-21
76.1%
#10430: fix: remove Minimax from isReasoningTagProvider
by echoedinvoker · 2026-02-06
75.7%
#10998: fix(agents): pass session thinking/reasoning levels to session_stat...
by wony2 · 2026-02-07
75.4%
#6685: fix: suppress thinking leak for Synthetic reasoning models
by AkiLetschne · 2026-02-01
75.3%