Find answers from the community

Updated last year

I'm inputting a `system_prompt` kwarg

At a glance

The community members are discussing issues with customizing the prompt or system prompt of a ReAct agent. They discover that the system_prompt kwarg passed to the agent's creation does not seem to have any effect. After examining the source code, they determine that the from_tools() method does not actually use this kwarg.

The community members suggest that to customize the prompt, one needs to modify the underlying ReActChatFormatter. However, they note that this can be challenging. One community member decides to contribute to the project by creating their own version of the ReActChatFormatter, called ContextReActChatFormatter, which allows the user to input additional context to prime the agent beyond just the tool metadata.

There is no explicitly marked answer in the comments, but the community members collaborate to find a solution by modifying the existing framework.

I'm inputting a system_prompt kwarg into my ReAct Agent when creating from tools, but it doesn't seem to be having any effect on the agent. When I dig into the source code I'm having a hard time discerning whether ReAct agents really accept this kwarg and do anything with it?

Are we able to update the prompt or system prompt of a react agent?
L
n
22 comments
look at the top level from_tools() method, it indeed does not do anything with it
Thats what I saw. Wasn't really sure
That explains so much
I thought I was just a real shit prompt engineer
React agent is somewhat hard to customize prompts for

You need to customize the underlying ReActChatFormatter
Ive never actually done it lol
but looking at the code, thats where the action is
There is basically this big giant react system header
Yeah I found that header
I was going to modify it to include some context in the header.
yup, thats what I would do too πŸ™‚
My task is such that I need an Agent to be able to answer questions which require it to determine which REST APIs (exposed to the via OpenAPI tool specs) to call to answer the question. It may need to call more than once across several APIs, so a ReAct Agent is necessary. But I'd like to prime it with some underlying context not just on the metadata of the tools but of the data itself that the tools would return.
So if I could prime it with context I think I'd get some really good responses is all.
Ah, I was reading too fast. Could have figured this out by noticing the **kwargs aren't used anywhere in the from_tools method. Maybe that should be removed from the function arguments πŸ˜„ ?
it's actually a safety buffer for as_chat_engine() πŸ˜… yay kwargs abuse
Ah, well glad I asked anyway
Welp, you're absolutely right. The easiest way for this to get done is for me to make a contribution. My first one!

For now though, I'll have to monkeypatch it though because my company doesn't allow my enterprise github account to interact outside the enterprise :(. I'll make a branch and PR this weekend tho.
Kinda excited about it
niceee πŸ™‚ I will be there to review it! πŸ’ͺ
It worked! But in attempting to do this I realized how vast this library is. So I definitely broke some best practices/standards. This weekend I may ping you with my code and questions on how I should better integrate it with the framework.

But tl;dr I just ended up writing my own version of a ReActChatFormatter because really this is a ReActChatFormatter that allows the user to input some additional context to the agent that might prime it for its answers and tool selection beyond just the tool metadata. I wrote a new class called ContextReActChatFormatter. I suspect more revisions will be needed before its added accepted into the framework officially.
ooo interesting! Yea happy to help answer questions or refine it
Add a reply
Sign up and join the conversation on Discord