[BUG] System prompt is not honored
Describe the bug
The system prompt (agent description) is not honored. When asked to always format replies according to some formatting, e.g. HTML or a variant of Markdown, it will always respond in standard Markdown.
Steps To Reproduce
- In the agent description, give in instruction that the reply must use a specific format, e.g. Telegram's MarkdownV2, HTML, etc...
- generateText with prompt where the reply will usually include formatting
const telegramAgentSystemPrompt = "You are a telegram bot that can answer questions. Your replies should always be in Telegram's HTML formatting."
export const telegramAgent = new Agent({
name: "Telegram Bot",
description: telegramAgentSystemPrompt,
llm: new VercelAIProvider(),
// model: openaiCompatible("openai/gpt-4o"), // tried with requesty.ai also
model: openai("gpt-4o"),
// also tried with markdown: false
tools: [],
});
const response = await telegramAgent.generateText(msgText, {
userId: username,
conversationId: `tg:${chatId}`,
});
console.log(response.text); // always in standard Markdown
Expected behavior
The response should be in the correct text format as specified in the system prompt.
Example system prompt: "You are a telegram bot that can answer questions. Your replies should always be in Telegram's HTML formatting."
Example prompt: "I'd like to create an app written in nodejs"
Actual Response Text (console.log)
Response: Creating an app with Node.js is a great choice! Here's a general guide to help you get started:
1. **Define Your App's Purpose and Features:**
- Clearly outline what your app will do and the key features it will offer.
- Consider user needs and how your app will address them.
2. **Set Up Your Development Environment:**
- Install Node.js and npm (Node Package Manager) on your computer.
- Choose a code editor like Visual Studio Code for development.
...
Expected Response Text
<b>Response:</b> Creating an app with Node.js is a great choice! Here's a general guide to help you get started:<br><br>
1. <b>Define Your App's Purpose and Features:</b><br>
- Clearly outline what your app will do and the key features it will offer.<br>
- Consider user needs and how your app will address them.<br><br>
2. <b>Set Up Your Development Environment:</b><br>
- Install Node.js and npm (Node Package Manager) on your computer.<br>
- Choose a code editor like Visual Studio Code for development.
...
Packages
- "@ai-sdk/openai": "^1.3.10"
- "@ai-sdk/openai-compatible": "^0.2.13"
- "@voltagent/cli": "^0.1.1"
- "@voltagent/core": "^0.1.2"
- "@voltagent/vercel-ai": "^0.1.1"
Additional Context
No response
[BUG] System prompt is not honored
Describe the bug
The system prompt (agent description) is not honored. When asked to always format replies according to some formatting, e.g. HTML or a variant of Markdown, it will always respond in standard Markdown.
Steps To Reproduce
- In the agent description, give in instruction that the reply must use a specific format, e.g. Telegram's MarkdownV2, HTML, etc...
- generateText with prompt where the reply will usually include formatting
const telegramAgentSystemPrompt = "You are a telegram bot that can answer questions. Your replies should always be in Telegram's HTML formatting." export const telegramAgent = new Agent({ name: "Telegram Bot", description: telegramAgentSystemPrompt, llm: new VercelAIProvider(), // model: openaiCompatible("openai/gpt-4o"), // tried with requesty.ai also model: openai("gpt-4o"), // also tried with markdown: false tools: [], });const response = await telegramAgent.generateText(msgText, { userId: username, conversationId: `tg:${chatId}`, }); console.log(response.text); // always in standard MarkdownExpected behavior
The response should be in the correct text format as specified in the system prompt.
Example prompt: "I'd like to create an app written in nodejs"
Actual Response Text (console.log)
Response: Creating an app with Node.js is a great choice! Here's a general guide to help you get started: 1. **Define Your App's Purpose and Features:** - Clearly outline what your app will do and the key features it will offer. - Consider user needs and how your app will address them. 2. **Set Up Your Development Environment:** - Install Node.js and npm (Node Package Manager) on your computer. - Choose a code editor like Visual Studio Code for development. ...Expected Response Text
<b>Response:</b> Creating an app with Node.js is a great choice! Here's a general guide to help you get started:<br><br> 1. <b>Define Your App's Purpose and Features:</b><br> - Clearly outline what your app will do and the key features it will offer.<br> - Consider user needs and how your app will address them.<br><br> 2. <b>Set Up Your Development Environment:</b><br> - Install Node.js and npm (Node Package Manager) on your computer.<br> - Choose a code editor like Visual Studio Code for development. ...Packages
- "@ai-sdk/openai": "^1.3.10"
- "@ai-sdk/openai-compatible": "^0.2.13"
- "@voltagent/cli": "^0.1.1"
- "@voltagent/core": "^0.1.2"
- "@voltagent/vercel-ai": "^0.1.1"
Additional Context
No response
Hey @profound7
Here is my answer:
The issue you're experiencing with the system prompt not being honored in VoltAgent, specifically regarding the formatting of responses, can be attributed to a few potential factors:
-
Agent Configuration: The
Agentclass in VoltAgent allows for configuration of various properties, including thedescriptionwhich acts as the system prompt. However, if themarkdownproperty is set totrue, the agent is instructed to format responses using Markdown syntax by default. This could override any specific formatting instructions given in the description. In your case, even though you tried settingmarkdown: false, it seems the agent still defaults to standard Markdown. -
LLM Behavior: The behavior of the Large Language Model (LLM) might not fully adhere to the system prompt if the model's default behavior is to output in Markdown. This could be due to the model's training data or inherent biases towards certain formats.
-
Implementation Details: There might be an implementation detail within the
generateTextmethod or the LLM provider (VercelAIProvider) that defaults to Markdown formatting, regardless of the system prompt. This could be a bug or a limitation in the current version of the library.
To address this issue, you might consider the following steps:
- Verify Configuration: Double-check the agent's configuration to ensure that all properties are set correctly and that there are no conflicting settings.
- Custom Formatting Logic: Implement custom logic to post-process the response text to convert it into the desired format (e.g., HTML) if the LLM does not natively support it.
- Report the Issue: If the problem persists, consider reporting it to the VoltAgent development team for further investigation, as it might be a bug that needs addressing in future updates.
For more detailed information on configuring agents and handling text formatting, you can refer to the Agent Overview documentation.
Trust Score: 🟡 50%
Sources:
👀 View on Gurubase for a better UX
Tag @gurubase to ask me a question.
Hey @profound7 👋,
Thanks a lot for bringing this up.
I tested the same prompt (You are a telegram bot that can answer questions. Your replies should always be in Telegram's HTML formatting.) with agno, and it worked as you expected there.
It looks like in our case, the model sometimes treats the system message more like guidance unless it’s phrased very strictly.
I’m currently investigating this behavior in more detail. For now, you can continue using a stricter system prompt like:
You must strictly format every reply using Telegram HTML formatting. Never, under any circumstances, return plain text. Always wrap your answers appropriately using HTML tags like <b>, <i>, <code>, etc.
I’ll update soon to improve this and make sure it works more reliably without needing a detailed prompt.
Thanks again for your help and feedback. it’s really valuable!
Quick update: I tried this again today, and Agno didn’t give a good response. I’ll also test it with a few other frameworks and see what we can do!
I looked into it and it seems that other frameworks give better results with strict prompts. I think we can close this issue for now. Thank you @profound7