-
Notifications
You must be signed in to change notification settings - Fork 271
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
Add system prompts independently of history of messages #531
Comments
Yes as of now, async def _prepare_messages(
self, user_prompt: str, message_history: list[_messages.ModelMessage] | None, run_context: RunContext[AgentDeps]
) -> list[_messages.ModelMessage]:
if message_history:
# shallow copy messages
messages = message_history.copy()
messages.append(_messages.ModelRequest([_messages.UserPromptPart(user_prompt)]))
else:
parts = await self._sys_parts(run_context)
parts.append(_messages.UserPromptPart(user_prompt))
messages: list[_messages.ModelMessage] = [_messages.ModelRequest(parts)]
return messages |
Hey @HamzaFarhan, thanks for your quick answer. Is this to prevent the parts to repeat? Is there a simpler way to inject a system prompt into messages? I could do workarounds here, to accept system events to be injected as part of the conversation, do you see the Agents supporting this in the future? Regards |
@josead I'm not sure actually, I did try manually calling self._sys_parts and replacing the system prompt in the message_history when passing it in and it worked. |
Hello! I wanted to know how to make the @agent.system_prompt decorator being called on every run, when there is history of messages added. I'm basically trying to evaluate the dependencies on each run (the dependencies will change independently of the run and I don't want to use a tool for this because is not needed)
Here is how to reproduce:
The function get_current_status_of_tasks only gets called once.
Am I doing something wrong here? Is this expected? Thanks in advance!
The text was updated successfully, but these errors were encountered: