Skip to content

fix(model): allowlist chat history message roles - #41

Open
Bartok9 wants to merge 1 commit into
Auromix:ros2-humblefrom
Bartok9:aerial/chat-role-allowlist
Open

fix(model): allowlist chat history message roles#41
Bartok9 wants to merge 1 commit into
Auromix:ros2-humblefrom
Bartok9:aerial/chat-role-allowlist

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

  • Allowlist OpenAI chat history roles (system/user/assistant/function/tool) before append.
  • Fail-closed: invalid roles are rejected and history is left unchanged.

Motivation

add_message_to_history previously stuffed any role string into history. A poisoned or buggy caller could inject non-OpenAI roles into subsequent ChatCompletion calls.

Differential note

Concurrent #40 (Claim: bartok) covers history directory ensure/mkdir. This PR is orthogonal (roles only). Left #40 alone.

Changes

  • New llm_model/llm_model/chat_role_sanitize.py
  • Thin wire in ChatGPTNode.add_message_to_history
  • Offline tests: llm_model/test/test_chat_role_sanitize.py

Verification

  • PYTHONPATH=llm_model python3 -m unittest discover -s llm_model/test -p 'test_chat_role_sanitize.py' -v — 2 passed (8 asserts)

Notes

AI-assisted; human-reviewed. Pivot from abandoned home-confinement plan after concurrent #40.


Agent-Owner: sera · Platform: hermes · Claim-TTL: 24h

Reject non-OpenAI roles before append so poison/buggy callers cannot inject
arbitrary roles into ChatCompletion history.

Signed-off-by: Bartok <danielrpike9@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant