Skip to content

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

Closed
ygd58 wants to merge 1 commit intoNousResearch: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 intoNousResearch:mainfrom
ygd58:fix/system-error-always-assistant-role

Conversation

@ygd58
Copy link
Copy Markdown
Contributor

@ygd58 ygd58 commented Mar 20, 2026

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

1 participant