Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration and parameters for all_messages() and new_messages() #496

Open
pietz opened this issue Dec 19, 2024 · 4 comments
Open

Configuration and parameters for all_messages() and new_messages() #496

pietz opened this issue Dec 19, 2024 · 4 comments

Comments

@pietz
Copy link

pietz commented Dec 19, 2024

It would be helpful if the all_messages() and new_messages() methods had an option to exclude the system prompt like all_messages(system_prompt=False). This would probably be a better default behavior too. Why?

Well, when do you use these methods?

1. Passing messages to the client/frontend

@app.post("/chat")
async def chat(data):
    ...
    result = await agent.run(data.message, message_history=data.history)
    return result.all_messages()

You probably don't want to pass the system prompt along.

2. When storing messages in a database

...
result = await agent.run(data.message, message_history=data.history)
db.table("conversations").insert(result.all_messages_json())
...

You probably don't want to store the system prompt for every conversation.

3. When handing over a conversation to a different agent

result1 = agent1.run(message, message_history=history)
...
# handover detected
result2 = agent2.run(message, message_history=result1.all_messages())

You want the chat messages for context, but the system prompt of the new agent.


More parameters to exclude tool calls or just tool call responses would be another great addition, I think.

@samuelcolvin
Copy link
Member

I'm fine to add these parameters, but I do want to point out that current Agent won't inject a system prompt if any messages are passed to a run. So we probably want to alter the logic to insert a system prompt if it's not already in the messages.

@HamzaFarhan
Copy link

@samuelcolvin So right now if Agents A and B have their own system prompts and dynamic system prompts, and we pass the history from A to B, B would take A's system prompt + whatever was dynamically added in it and ignore its own system prompt and won't even bother calling the dynamic system tool right?

@josead
Copy link
Contributor

josead commented Dec 23, 2024

but I do want to point out that current Agent won't inject a system prompt if any messages are passed to a run.

Hey @samuelcolvin, I want to link to #531 Hamza and I discussed Today.
I see some cases where having this ability would be beneficial. If this is something you are planning to support, I want to see how I can contribute with the use cases and, of course, make a PR if necessary!

@samuelcolvin
Copy link
Member

Hi @josead, yes please create a PR.

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

No branches or pull requests

4 participants