fix: strip chatgpt transcript tags from agent messages#735
Open
ousamabenyounes wants to merge 2 commits into
Open
fix: strip chatgpt transcript tags from agent messages#735ousamabenyounes wants to merge 2 commits into
ousamabenyounes wants to merge 2 commits into
Conversation
Contributor
Greptile SummaryThis PR strips ChatGPT-style transcript tags before messages are appended to the SDK session. The main changes are:
Confidence Score: 4/5The changed message conversion path needs a fix before merging.
strix/core/agents.py Important Files Changed
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
strix/core/agents.py:268-271
**User Prompts Lose Literal Tags**
When a user sends text through the CLI, TUI, or resume instruction path, this line strips `<user>`, `<final>`, `<analysis>`, and the other transcript tags before the sender check. A prompt that asks the agent to inspect XML/HTML or preserve a snippet containing those literal tags is changed before it reaches the SDK session, so the model receives different input than the user provided.
```suggestion
sender = str(message.get("from", "unknown"))
content = str(message.get("content", ""))
if sender == "user":
return cast("TResponseInputItem", {"role": "user", "content": content})
content = _strip_chatgpt_transcript_tags(content)
```
### Issue 2 of 2
strix/core/agents.py:31-34
**Attributed Transcript Tags Survive**
This pattern only removes bare tags such as `<final>` and `</final>`. If an agent message contains the same transcript tags with attributes or self-closing syntax, such as `<final reason="done">` or `<analysis/>`, those tags stay in the session item and can still be resent to an OpenAI-compatible provider that rejects transcript markup.
```suggestion
_CHATGPT_TRANSCRIPT_TAG_RE = re.compile(
rf"</?(?:{'|'.join(_CHATGPT_TRANSCRIPT_TAGS)})(?:\s+[^>]*)?\s*/?>",
flags=re.IGNORECASE,
)
```
Reviews (1): Last reviewed commit: "fix: strip chatgpt transcript tags from ..." | Re-trigger Greptile |
Contributor
Author
|
Addressed the two Greptile review comments in a23be85.
Verification: Revert proof: with the production fix reverted and the new tests kept, the targeted file fails with 2 failed / 1 passed. |
0xallam
force-pushed
the
main
branch
3 times, most recently
from
July 13, 2026 23:50
44e87ca to
daf39a2
Compare
Preserve literal transcript-like tags in user prompts. Strip attributed and self-closing transcript tags from non-user session messages. RED->GREEN: new regression tests fail with the production fix reverted, then pass with 3 passed. Full suite: 145 passed, 2 warnings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix #118
Strip ChatGPT-style transcript tags from messages before appending them to the SDK session, so agent-originated content cannot be resent to OpenAI-compatible providers with rejected tags like
<analysis>,<channel>, or<final>.Follow-up review fixes:
<final reason="done">and<analysis/>from non-user messages.Also annotates the descendant task list in the same module so the touched file passes pyright.
Test verification (RED -> GREEN)
RED with the follow-up production fix reverted, while keeping the new regression tests:
GREEN with the follow-up fix applied:
Full suite:
Additional targeted validation:
Global quality baseline notes, not introduced by this PR: