Orphaned think/reasoning tags appearing in user-facing responses
Cluster 4285 · agent. Data as of
Nothing open on GitHub. Fix merged in #4311 on 31 Mar 2026. Check it covers your case.
The short answer
- Known?
- Yes. 3 related items grouped here, 1 issue already closed.
- Fix event
- A fix was merged to main in PR #4311. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
resolved, deciding PR #4311. That is separate from the fix event. - Still open
- Nothing open on GitHub.
The members concern orphaned think or reasoning tags, specifically closing </think> tags, appearing in user-facing responses. One is a bug report and two are identically titled pull requests proposing to strip such tags; the titles alone do not show whether any change was merged or works.
Open issues0
Open PRs0
Fixes on record
-
#4311 fix: strip orphaned think/reasoning tags from user-facing responses
files:
run_agent.py,tests/test_run_agent.pyShow the diff
-
run_agent.py@@ -1389,6 +1389,7 @@ def _strip_think_blocks(self, content: str) -> str: content = re.sub(r'<thinking>.*?</thinking>', '', content, flags=re.DOTALL | re.IGNORECASE) content = re.sub(r'<reasoning>.*?</reasoning>', '', content, flags=re.DOTALL) content = re.sub(r'<REASONING_SCRATCHPAD>.*?</REASONING_SCRATCHPAD>', '', content, flags=re.DOTALL) + content = re.sub(r'</?(?:think|thinking|reasoning|REASONING_SCRATCHPAD)>\s*', '', content, flags=re.IGNORECASE) return content def _looks_like_codex_intermediate_ack( -
tests/test_run_agent.py@@ -230,6 +230,27 @@ def test_multiline_block_removed(self, agent): assert "line1" not in result assert "visible" in result + def test_orphaned_closing_think_tag(self, agent): + result = agent._strip_think_blocks("some reasoning</think>actual answer") + assert "</think>" not in result + assert "actual answer" in result + + def test_orphaned_closing_thinking_tag(self, agent): + result = agent._strip_think_blocks("reasoning</thinking>answer") + assert "</thinking>" not in result + assert "answer" in result + + def test_orphaned_opening_think_tag(self, agent): + result = agent._strip_think_blocks("<think>orphaned reasoning without close") + assert "<think>" not in result + + def test_mixed_orphaned_and_paired_tags(self, agent): + text = "stray</think><think>paired reasoning</think> visible" + result = agent._strip_think_blocks(text) + assert "</think>" not in result + assert "<think>" not in result + assert "visible" in result + class TestExtractReasoning: def test_reasoning_field(self, agent):
-
1 PR closed without merging
From the close comments: merged via another change 1
-
#4286 fix: strip orphaned think/reasoning tags from user-facing responses · merged via another change →
#4311
Closed issues · 1
- Closed#4285[Bug]: Orphaned </think> closing tags leak into user-facing responses
How this cluster was grouped
-
Link evidence (
structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference. -
Pairwise link density
0.67: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Subsystem
- agent
- Merged PRs
- #4311
- Closed issues
- 1
- Attempts
- 1 PR closed without merging
- Fix link checked
- 31 Mar 2026. This confirmation is old and may be out of date (a revert or reopen would not have invalidated it here); re-verify.