Skip to content

fature: Multi context smart agent + multi context validation#91

Draft
carlesonielfa wants to merge 1 commit into
mainfrom
smart-multi-context
Draft

fature: Multi context smart agent + multi context validation#91
carlesonielfa wants to merge 1 commit into
mainfrom
smart-multi-context

Conversation

@carlesonielfa

Copy link
Copy Markdown
Contributor

Summary

  • Preserve one Context per Smart Agent tool call instead of flattening results into one synthetic context.
  • Add hierarchical multi-context validation with per-context answers and citations plus a global missing-information query.
  • Prune each context independently while retaining summary-only contexts and dropping irrelevant contexts.

Tests

  • Add deterministic and cassette-backed coverage for relevance, summary-only answers, chunk pruning, and missing information.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_missing flow 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()
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.

2 participants