fature: Multi context smart agent + multi context validation#91
Draft
carlesonielfa wants to merge 1 commit into
Draft
fature: Multi context smart agent + multi context validation#91carlesonielfa wants to merge 1 commit into
carlesonielfa wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces end-to-end multi-context handling: SmartAgent now preserves each tool-returned Context independently, and ContextAgents can validate/prune multiple contexts in a single pass with per-context partial answers/citations plus a global “missing information” query.
Changes:
- Add multi-context validation prompt + JSON schema and a
validate_contexts_and_answer/save_contexts_and_return_missingflow to prune/save contexts independently. - Update SmartAgent to collect and return a list of contexts (instead of flattening into one synthetic context), and adjust tests accordingly.
- Add deterministic + VCR cassette-backed tests covering relevance filtering, summary-only contexts, chunk pruning, and global missing-info reporting.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| hyperforge/src/hyperforge/context/agent.py | Adds multi-context validation + saving/pruning logic. |
| hyperforge/src/hyperforge/prompts.py | Introduces the multi-context validation prompt template + JSON schema. |
| hyperforge/src/hyperforge/memory/memory.py | Extends save_context to optionally index contexts under a parent agent id. |
| agents/smart/src/hyperforge_smart/agent.py | Switches SmartAgent to return and retain multiple contexts per tool call. |
| agents/smart/tests/test_smart_mcp_perplexity.py | Updates expectations to handle multiple returned contexts. |
| agents/smart/tests/test_contexts.py | Adds unit test ensuring tool results preserve original contexts. |
| agents/summarize/src/hyperforge_summarize/agent.py | Adds a TODO note about exposing summaries when forcing chunk citations. |
| hyperforge/tests/context/test_validation.py | Adds multi-context validation tests (mocked + VCR-backed). |
| hyperforge/tests/context/cassettes/test_validation/test_multi_context_validation_keeps_relevant_contexts.yaml | VCR cassette for relevance filtering behavior. |
| hyperforge/tests/context/cassettes/test_validation/test_multi_context_validation_keeps_summary_and_discards_chunks.yaml | VCR cassette for summary-only context retention behavior. |
| hyperforge/tests/context/cassettes/test_validation/test_multi_context_validation_prunes_irrelevant_chunks.yaml | VCR cassette for chunk-level pruning behavior. |
| hyperforge/tests/context/cassettes/test_validation/test_multi_context_validation_reports_globally_missing_information.yaml | VCR cassette for global missing-info query behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+94
to
+97
| t0 = time() | ||
| model = self.context_config.context_validation_model | ||
| module = self.context_config.module | ||
| ident = self.context_config.id if self.context_config.id else "default" |
Comment on lines
+529
to
+530
| else: | ||
| context.prune_to_citations() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Contextper Smart Agent tool call instead of flattening results into one synthetic context.Tests