Skip to content

Comments

Revert "append system prompt"#1296

Merged
iceljc merged 1 commit intomasterfrom
revert-1295-bugfix/append-system-instruction
Feb 19, 2026
Merged

Revert "append system prompt"#1296
iceljc merged 1 commit intomasterfrom
revert-1295-bugfix/append-system-instruction

Conversation

@iceljc
Copy link
Collaborator

@iceljc iceljc commented Feb 19, 2026

Reverts #1295

@iceljc iceljc merged commit 90392d0 into master Feb 19, 2026
1 check was pending
@qodo-code-review
Copy link

Review Summary by Qodo

Revert system prompt appending order change

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Revert system prompt appending order change from PR #1295
• Move system messages, knowledges, and samples before conversation messages
• Restore original message construction sequence in chat completion provider
• Apply same message ordering fix to realtime completion provider
Diagram
flowchart LR
  A["Instruction & Functions"] --> B["System Messages<br/>Knowledges & Samples"]
  B --> C["Conversation Messages"]
  C --> D["Chat Completion"]
Loading

Grey Divider

File Changes

1. src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs 🐞 Bug fix +35/-38

Reorder message construction in chat completion

• Moved system message, knowledge, and sample message construction before conversation message
 processing
• Reordered message building to place system context ahead of user/assistant conversation history
• Maintains function rendering logic in the same position
• Restores original message sequence that was changed in PR #1295

src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs


2. src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs 🐞 Bug fix +31/-35

Reorder message construction in realtime completion

• Moved system message, knowledge, and sample message construction before conversation message
 processing
• Reordered function rendering to occur before conversation message handling
• Aligns message ordering with chat completion provider changes
• Restores original message sequence for realtime completion

src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Advisory comments

1. Realtime prompt ordering changed 🐞 Bug ✓ Correctness
Description
Realtime provider now builds system instruction/knowledges/samples and tool definitions before
appending conversation messages, which can alter model behavior compared to the previous ordering.
This is likely intentional (system-first), but should be validated via tests or targeted QA since it
affects live audio interactions.
Code

src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs[R578-608]

+        if (!string.IsNullOrWhiteSpace(instruction))
+        {
+            messages.Add(new SystemChatMessage(instruction));
+        }
+
+        foreach (var function in functions)
+        {
+            if (!agentService.RenderFunction(agent, function, renderData))
+            {
+                continue;
+            }
+
+            var property = agentService.RenderFunctionProperty(agent, function, renderData);
+
+            options.Tools.Add(ChatTool.CreateFunctionTool(
+                functionName: function.Name,
+                functionDescription: function.Description,
+                functionParameters: BinaryData.FromObjectAsJson(property)));
+        }
+
+        if (!string.IsNullOrEmpty(agent.Knowledges))
+        {
+            messages.Add(new SystemChatMessage(agent.Knowledges));
+        }
+
+        var samples = ProviderHelper.GetChatSamples(agent.Samples);
+        foreach (var sample in samples)
+        {
+            messages.Add(sample.Role == AgentRole.User ? new UserChatMessage(sample.Content) : new AssistantChatMessage(sample.Content));
+        }
+
Evidence
The realtime provider’s PrepareOptions now adds system message, function tools, knowledges, and
samples before the filtered conversation messages. This mirrors the chat provider’s system-first
ordering and impacts the instruction/context seen by the realtime model.

src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs[555-639]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Realtime message ordering is behaviorally significant and can change outputs. This PR changes the ordering; ensure it is intentional and protected by tests/QA.

### Issue Context
Realtime sessions can be sensitive to instruction/context construction because `session.update` instructions and tool configuration directly influence model behavior.

### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs[555-639]
- src/Plugins/BotSharp.Plugin.OpenAI/Providers/Realtime/RealTimeCompletionProvider.cs[320-365]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

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