feat: Add structured output (constrained decoding) support for agentic memory fact extraction#4824
Conversation
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 96c6ff8.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Reviewer Guide 🔍(Review updated until commit 96c6ff8)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 96c6ff8 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 28b697b
Suggestions up to commit f3621f5
Suggestions up to commit e999b8d
Suggestions up to commit 559c9ad
Suggestions up to commit af9507c
|
Signed-off-by: Emerson Havener <emersonhavener@gmail.com>
4eac4a3 to
89b5488
Compare
|
Persistent review updated to latest commit 89b5488 |
Signed-off-by: Emerson Havener <emersonhavener@gmail.com>
|
Persistent review updated to latest commit acb2315 |
Signed-off-by: Emerson Havener <emersonhavener@gmail.com>
Signed-off-by: Emerson Havener <emersonhavener@gmail.com>
|
Persistent review updated to latest commit 559c9ad |
Signed-off-by: Emerson Havener <emersonhavener@gmail.com>
|
Persistent review updated to latest commit e999b8d |
|
Persistent review updated to latest commit f3621f5 |
Signed-off-by: Emerson Havener <emersonhavener@gmail.com>
…nsearch-project#2 Signed-off-by: Emerson Havener <emersonhavener@gmail.com>
|
Persistent review updated to latest commit 96c6ff8 |
Description
Adds structured output (constrained decoding) support for agentic memory fact extraction. When a connector's predict action has
supports_structured_output: true,MemoryContainerHelperresolves the provider from the connector URL and injects a provider-specific JSON schema into fact-extraction requests.HttpConnectorreads_*_json/_*_additions_jsonparameters and injects them as top-level fields in the outgoing request body, so the provider enforces output structure at the token level rather than relying on prompt instructions.Implemented providers: OpenAI, Azure OpenAI, DeepSeek, Ollama, Cohere v2, Google Gemini/Vertex AI, Amazon Bedrock Converse
How it works
ConnectorAction— adds asupportsStructuredOutputboolean field (defaultfalse); wire-serialized for clusters ≥ 3.7.0 only.HttpConnector.injectStructuredOutputParams— reads_<X>_json/_<X>_additions_jsonparameters and injects them as top-level fields in the outgoing request body.MemoryContainerHelper.getStructuredOutputParameters— async lookup that resolves the model's connector, checks the flag, and returns the provider-specific schema parameters. Returns empty map on any failure; callers fall back to prompt enforcement.MemoryProcessingService— merges structured output params into the predict request when available, skipping the prompt enforcement sentence. Falls back gracefully on lookup failure.Manual testing
Ollama : A smoke test via a direct _predict call with _response_format_json confirmed that HttpConnector.injectStructuredOutputParams correctly reads the _*_json naming convention and injects response_format into the Ollama request body. Ollama then enforces the schema at the token level, returning {"facts": ["The user prefers dark mode."]} instead of free-forming the structure.
Bedrock Converse (claude-sonnet-4-6)
Related Issues
Resolves #4799
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.