Skip to content

Compact MCP evidence query responses#2325

Draft
mahikaw wants to merge 1 commit into
mainfrom
dev/mahikaw/mcp-evidence-truncation
Draft

Compact MCP evidence query responses#2325
mahikaw wants to merge 1 commit into
mainfrom
dev/mahikaw/mcp-evidence-truncation

Conversation

@mahikaw

@mahikaw mahikaw commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

PR description:

Summary

  • Compact format="evidence" MCP query responses by trimming verbose evidence text
  • Preserve all evidence items and citation metadata so agents can still see top-k results
  • Add coverage that verifies long evidence chunks are compacted without dropping hits

Why

MCP evidence responses can exceed the agent-visible tool output budget because each hit includes full chunk text. In Harbor/
Codex evals this caused function_call_output truncation, so the agent sometimes saw only a subset of the retrieved top-k
candidates even though the backend returned all 10.

This change keeps citation/source/page/score metadata intact and caps evidence text length server-side, including when an
agent asks for a larger text budget.

Testing

  • uvx pre-commit run --files nemo_retriever/src/nemo_retriever/service/mcp_server.py nemo_retriever/tests/ test_service_mcp.py
  • uv run --project nemo_retriever --no-dev --extra service --extra dev pytest nemo_retriever/tests/test_service_mcp.py -q

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

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.

1 participant