fix: classify OpenAI developer messages as system context - #18
Merged
royalpinto007 merged 1 commit intoSep 14, 2026
Merged
royalpinto007 merged 1 commit into
royalpinto007 merged 1 commit into
Conversation
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.
What & why
Closes #10.
OpenAI chat messages with the
developerrole currently fall through to the user segment, overstating user context and understating system instructions. Classify them with system instructions while preserving the original role, content, and turn.Changes
developeralongside the other OpenAI roles during format detection.Segment.SYSTEM.Validation
python -X utf8 -m pytest: 61 passed, both with.[dev]and with.[dev,tiktoken]installed (Python 3.12 on Windows).ruff check .: passed.ruff format --check src/ctxlens/parsers/openai_chat.py tests/test_parsers.py: passed.git diff --check: passed.The UTF-8 flag is needed on this Windows host because the existing HTML-output test calls
read_text()without an encoding; with the host's default GBK encoding, that test raises a decoding error. No unrelated encoding behavior was changed.AI assistance was used to implement and validate this change.
Checklist
Closes #123)