Skip to content

fix(agent): always use role=assistant for system error messages, never role=user - #2236

Closed
ygd58 wants to merge 1 commit into
NousResearch:mainfrom
ygd58:fix/system-error-always-assistant-role
Closed

fix(agent): always use role=assistant for system error messages, never role=user#2236
ygd58 wants to merge 1 commit into
NousResearch:mainfrom
ygd58:fix/system-error-always-assistant-role

Conversation

@ygd58

@ygd58 ygd58 commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #2228

Problem

System error messages were dynamically assigned role="user" when the last message was "assistant". This misattributes system behavior to the user, confusing the model about conversation state.

Fix

Always use role="assistant" for system error messages. Added system_injected: true metadata flag to distinguish these from real assistant responses.

Consecutive assistant messages (if they occur) are the lesser evil and are already handled by _sanitize_api_messages() at API-call time.

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.

bug: system error messages injected with dynamic role, can appear as role=user

1 participant