Skip to content

test: Extract method to extract text from mcp result#3154

Open
Mofef wants to merge 4 commits intodeepset-ai:mainfrom
Mofef:mcp_coverage
Open

test: Extract method to extract text from mcp result#3154
Mofef wants to merge 4 commits intodeepset-ai:mainfrom
Mofef:mcp_coverage

Conversation

@Mofef
Copy link
Copy Markdown

@Mofef Mofef commented Apr 13, 2026

Proposed Changes:

While looking through the coverage report vor mcp_tool.py I found a section of untested duplicate code between the tool invokation and its async counter part. I extracted that part and added a test for it.

How did you test it?

Ran tests and linting accoding to contribution guidelines. Added a new test (AI generated) for the extracted method

Checklist

@Mofef Mofef requested a review from a team as a code owner April 13, 2026 14:38
@Mofef Mofef requested review from julian-risch and removed request for a team April 13, 2026 14:38
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 13, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added integration:mcp type:documentation Improvements or additions to documentation labels Apr 13, 2026
Copy link
Copy Markdown
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

Looks quite good to me already, main change request is about renaming method name.

def test_extract_first_text_element():
"""Test that extract_first_text skips non-text blocks and parses the first text block."""
result = json.dumps(
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's use an actual existing tool call result, for example search the tests in the haystack repo for "content": [

return resolved_headers


def extract_first_text_element(result: str) -> str | dict[str, Any]:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's rename to _extract_first_text_element

Comment on lines +68 to +70
Return the first text content block from an MCP tool response.

MCP tool responses may include mixed content types such as text, image, or
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Return the first text content block from an MCP tool response.
MCP tool responses may include mixed content types such as text, image, or
Return the first text content block from an MCP tool call result.
MCP tool call results may include mixed content types such as text, image, or

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:mcp type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants