Skip to content

fix(mcp): fix the timeout argument in MCPToolFunction class#1192

Merged
DavdGao merged 3 commits into
agentscope-ai:mainfrom
DavdGao:fix/mcp_timeout
Feb 6, 2026
Merged

fix(mcp): fix the timeout argument in MCPToolFunction class#1192
DavdGao merged 3 commits into
agentscope-ai:mainfrom
DavdGao:fix/mcp_timeout

Conversation

@DavdGao

@DavdGao DavdGao commented Feb 4, 2026

Copy link
Copy Markdown
Member

AgentScope Version

[The version of AgentScope you are working on, e.g. import agentscope; print(agentscope.__version__)]

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with pre-commit run --all-files command
  • All tests are passing
  • Docstrings are in Google style
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @DavdGao, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily addresses a critical bug in the MCPToolFunction where the timeout parameter was not being correctly passed to the timedelta constructor, leading to incorrect timeout behavior. It also enhances the clarity of the MCPToolFunction's initialization by providing a more comprehensive docstring. Additionally, the DashScopeRealtimeModel's capabilities are updated to reflect support for text input, and the project's development version is incremented.

Highlights

  • Bug Fix: MCPToolFunction Timeout: The MCPToolFunction class now correctly interprets the timeout argument as seconds when constructing a timedelta object, resolving a potential issue where timeouts were not applied as intended.
  • Documentation Enhancement: The docstring for the MCPToolFunction.__init__ method has been significantly expanded to provide clear and detailed explanations for all its parameters, improving code clarity and maintainability.
  • DashScope Realtime Model Modality Update: The DashScopeRealtimeModel now explicitly lists 'text' as a supported input modality, alongside 'audio' and 'image'.
  • Version Update: The project version has been updated from 1.0.14 to 1.0.15dev.
Changelog
  • src/agentscope/_version.py
    • Updated the __version__ string from "1.0.14" to "1.0.15dev".
  • src/agentscope/mcp/_mcp_function.py
    • Corrected the timedelta constructor call within MCPToolFunction.__init__ to explicitly use seconds=timeout instead of just timeout, ensuring the timeout is applied correctly.
    • Expanded the docstring for MCPToolFunction.__init__ to include detailed descriptions for all parameters: mcp_name, tool, wrap_tool_result, client_gen, session, and timeout.
  • src/agentscope/realtime/_dashscope_realtime_model.py
    • Added "text" to the support_input_modalities list in DashScopeRealtimeModel, indicating support for text input.
Activity
  • No human activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request primarily fixes a bug in the MCPToolFunction class where the timeout argument was incorrectly passed to timedelta, causing it to be interpreted as days instead of seconds. The fix correctly uses timedelta(seconds=timeout). While the main fix is correct, I've identified a couple of issues. Firstly, the new docstring in _mcp_function.py has a minor style guide violation. Secondly, an unrelated change in _dashscope_realtime_model.py enables 'text' as a supported input modality, but the implementation for handling text is marked with a TODO as non-functional, which could introduce a bug. I've left detailed comments and suggestions for both points.

Comment thread src/agentscope/realtime/_dashscope_realtime_model.py
Comment thread src/agentscope/mcp/_mcp_function.py Outdated
DavdGao and others added 2 commits February 4, 2026 15:01
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@DavdGao DavdGao merged commit 18567ae into agentscope-ai:main Feb 6, 2026
11 checks passed
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