Prevent oversized connector results from entering LLM context#87
Open
arnaugrispg wants to merge 10 commits into
Open
Prevent oversized connector results from entering LLM context#87arnaugrispg wants to merge 10 commits into
arnaugrispg wants to merge 10 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a safety budget for connector/tool outputs so oversized Smart Agent and MCP results are rejected before entering the LLM context, replacing them with bounded retry guidance and emitting traceable “Tool result rejected” steps.
Changes:
- Introduces
ResultPayloadBudget/OversizedResultandinspect_text_blocks()to detect oversized tool payloads and produce safe, non-sensitive retry guidance. - Adds configurable budget knobs (
max_tool_result_bytes,max_tool_result_item_bytes) toContextAgentConfig. - Integrates payload inspection + rejection steps into Smart Agent and MCP Agent execution paths, with new tests covering rejection/trace behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| hyperforge/tests/test_result_payload.py | Unit tests for payload inspection and safe rendering behavior. |
| hyperforge/src/hyperforge/result_payload.py | New budget/inspection utilities for rejecting oversized connector results. |
| hyperforge/src/hyperforge/context/config.py | Adds config fields to control max tool-result byte budgets. |
| agents/smart/tests/test_result_payload.py | Smart Agent tests for rejecting oversized Context/ToolError and recording safe steps. |
| agents/smart/src/hyperforge_smart/agent.py | Integrates result inspection and replaces oversized outputs with retry guidance + trace steps. |
| agents/mcp/tests/test_result_payload.py | MCP tests ensuring oversized content/structured/resources are rejected with safe history. |
| agents/mcp/src/hyperforge_mcp/agent.py | Adds payload extraction + budget checks and records “Tool result rejected” steps on overflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
carlesonielfa
left a comment
Contributor
There was a problem hiding this comment.
a comment regarding where we store the limits
carlesonielfa
approved these changes
Jul 23, 2026
Contributor
|
Will I be able to disable these limits in the MarkLogic MCP server? |
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.
Rejects oversized Smart Agent and MCP tool results before they enter the LLM context.
Oversized results are replaced with bounded retry guidance, allowing the agent to retry with narrower filters, pagination, aggregation, or summaries. Each rejection also emits a visible
Tool result rejectedstep with safe size metadata for traceability.