Skip to content

Conversation

@siddhantbhagat8
Copy link
Contributor

@siddhantbhagat8 siddhantbhagat8 commented Dec 2, 2025

Description

Changed the insertion logic to insert instructions after all system prompt parts

Simple append:

  1. anthropic.py
  2. google.py
  3. gemini.py
  4. bedrock.py

Insert at a particular position:
For models that build a messages list, count SystemPromptPart instances and insert at that index

  1. openai.py
  2. cohere.py
  3. groq.py
  4. mistral.py
  5. huggingface.py

Testing

I ran the tests locally, everything passed. If I should add a test for this change, please let me know the correct location for the test :)

Copy link
Collaborator

@DouweM DouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siddhantbhagat8 Thanks Siddhant! Please look at my notes and add a test in test_agent.py, by using both system_prompt and instructions decorators on one agent

@siddhantbhagat8
Copy link
Contributor Author

siddhantbhagat8 commented Dec 3, 2025

@siddhantbhagat8 Thanks Siddhant! Please look at my notes and add a test in test_agent.py, by using both system_prompt and instructions decorators on one agent

I believe I have addressed the core logic feedback as per my understanding :)

@siddhantbhagat8
Copy link
Contributor Author

@DouweM Sorry for bothering you but would love to get this over the line!

@DouweM
Copy link
Collaborator

DouweM commented Dec 9, 2025

@siddhantbhagat8 Sorry about the delay, I was at a conference last week and got a bit behind on PR review!

@siddhantbhagat8 siddhantbhagat8 force-pushed the sid/insert-instructions-at-end-of-sys-prompt branch from 4bcb9fc to b6144bb Compare December 15, 2025 07:56
@siddhantbhagat8
Copy link
Contributor Author

@DouweM Hope you had a great conference!
Sorry for the delay on my part, was slammed with work. I have added the tests for the big 3 (openai, anthropic, and google). Let me know if this is sufficient or if you'd like me to add the tests for the other models as well. More than happy to :)
Ready for your review whenever you get a chance!

@siddhantbhagat8
Copy link
Contributor Author

I believe the tests are failing due to connection timeouts and not because of the contents of the PR. Let me know if this PR is resulting in the failing tests

@siddhantbhagat8
Copy link
Contributor Author

@DouweM addressed the feedback!

@DouweM DouweM changed the title Insert Instructions at the end of System Prompt Insert agent instructions after system_prompts for models that don't natively support instructions Dec 15, 2025
@DouweM DouweM merged commit f512d65 into pydantic:main Dec 15, 2025
30 checks passed
@DouweM
Copy link
Collaborator

DouweM commented Dec 15, 2025

@siddhantbhagat8 Thanks Siddhant!

@siddhantbhagat8
Copy link
Contributor Author

@DouweM thanks for approving and merging!
If I may ask, what release will this change be a part of? And is there any way for me to track it as a contributor?

@DouweM
Copy link
Collaborator

DouweM commented Dec 15, 2025

@siddhantbhagat8 We release every day, so should be going up in a few hours :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants