Skip to content

Conversation

@vedant381
Copy link
Contributor

@vedant381 vedant381 commented Oct 15, 2025

This pull request updates how custom prompts are handled when generating fact retrieval messages in the memory module. The main change is to allow a custom prompt to fully override the default system prompt logic, while ensuring the response must be valid JSON. The logic for constructing prompts has been centralized in the getFactRetrievalMessages function.

Prompt customization improvements:

  • The getFactRetrievalMessages function now accepts an optional customPrompt parameter. If provided, it becomes the system prompt (with a requirement for valid JSON responses), and the user prompt is set to the parsed conversation. [1] [2]
  • The Memory class has been updated to always use getFactRetrievalMessages for constructing prompts, passing in customPrompt if set, simplifying and unifying prompt handling.

Fixes #3559

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Please delete options that are not relevant.

  • Unit Test
  • Test Script (please provide)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

@vedant381 vedant381 closed this Oct 21, 2025
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

Successfully merging this pull request may close these issues.

Error 400 'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'.

1 participant