Replies: 3 comments
|
The system_prompt parameter in ReActAgent is meant to provide initial instructions or context to guide the agent's behavior. However, it doesn't appear verbatim in LLM server logs because it's not sent as a raw system message. Instead, ReActAgent merges system_prompt into the formatter's context, which is then used to build a templated system header. This header becomes the first message in the chat input sent to the LLM, so what you see in the logs is the final, formatted system header—not your original system_prompt string. If your custom prompt is missing required placeholders (like {tool_desc} or {tool_names}) or is pre-formatted, the agent may not apply it or may silently fail to make LLM calls, which can also result in it not appearing in logs. To ensure your prompt is used, pass it as a template string with the required variables and update it using the agent's update_prompts method if needed. For more details, see the implementation and recent discussions: To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
|
The Why it does not show in logs: To verify it is being used: agent = ReActAgent(
tools=tools,
llm=llm,
system_prompt="You are a helpful pirate. Say arrr often.",
verbose=True,
)
# Check the full prompt template
print(agent._get_prompt_str()) # Should include your promptIf you need a true system message: from llama_index.core.llms import ChatMessage, MessageRole
# Some LLMs handle system messages differently
llm = OpenAI(
model="gpt-4o",
system_prompt="You are a helpful pirate.", # LLM-level system
)
agent = ReActAgent(
tools=tools,
llm=llm,
# This adds to the ReAct template
system_prompt="Additional context here.",
)Best practice: We customize ReActAgent at Revolution AI — the merged prompt approach works well once you understand the flow. |
|
Setting system_prompt on ReActAgent! At RevolutionAI (https://revolutionai.io) we customize agent behavior. Direct approach: from llama_index.core.agent import ReActAgent
agent = ReActAgent.from_tools(
tools=tools,
llm=llm,
system_prompt="You are a helpful assistant specialized in..."
)Or via chat engine: agent = ReActAgent.from_tools(
tools=tools,
llm=llm,
chat_history=[{
"role": "system",
"content": "Your system prompt here"
}]
)Pro tip: Keep system prompts concise — agents perform better with focused instructions! |
Uh oh!
There was an error while loading. Please reload this page.
What is the purpose of the system_prompt parameter in ReActAgent()? When I set it, it doesn't appear in the LLM server logs!"
agent = ReActAgent( tools=query_tools, llm=models.llm, system_prompt=system_prompt, verbose=True, )All reactions