Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
c530489
chore(cli): ruff rewrite
Dt8333 Oct 28, 2025
8b6d235
chore(cli): add missing type annotations
Dt8333 Oct 28, 2025
ffc535f
chore(core.agent): ruff rewrite
Dt8333 Oct 28, 2025
1e59225
chore(core.agent): add missing type annotations
Dt8333 Oct 28, 2025
a60d6fe
fix(core): 重命名__dict__方法避免类型冲突
Dt8333 Oct 28, 2025
5ea6e13
chore(core.config): ruff rewrite
Dt8333 Oct 28, 2025
c414039
chore(core.config): add missing type annotations
Dt8333 Oct 28, 2025
27c815d
chore(core.convmgr): ruff rewrite
Dt8333 Oct 28, 2025
d575969
chore(core.convmgr): add missing type annotations
Dt8333 Oct 28, 2025
b17f50f
chore(core.db): ruff rewrite
Dt8333 Oct 28, 2025
504c6d8
chore(core.db): add missing type annotations
Dt8333 Oct 28, 2025
4a54442
chore(core.kb): ruff rewrite
Dt8333 Oct 28, 2025
556cf55
chore(core.kb): add missing type annotations
Dt8333 Oct 28, 2025
a6bd814
chore(core.db): ruff rewrite missing file
Dt8333 Oct 29, 2025
f0b8020
chore(core.message): ruff rewrite
Dt8333 Oct 29, 2025
ef631ee
chore(core.message): add missing type annotations
Dt8333 Oct 29, 2025
9a6dd40
chore(core.pipeline): ruff rewrite
Dt8333 Oct 29, 2025
d85a395
chore(core.pipeline): add missing type annotations
Dt8333 Oct 29, 2025
9da5d1d
chore(core.platform): ruff rewrite
Dt8333 Oct 29, 2025
b71ba19
chore(core.provider): ruff rewrite
Dt8333 Oct 30, 2025
28d70db
chore(core.star): ruff rewrite
Dt8333 Oct 30, 2025
595f766
chore(core.message): ruff rewrite
Dt8333 Oct 30, 2025
932d76d
chore(core.utils): ruff rewrite
Dt8333 Oct 30, 2025
70a9186
refactor: 为大量构造方法及相关方法添加返回类型 None 注解
Dt8333 Dec 11, 2025
39463e9
refactor: 为大量函数添加返回 None 的类型注解
Dt8333 Dec 11, 2025
8d766f0
refactor: 为 save_mcp_config 添加返回类型注解 bool
Dt8333 Dec 11, 2025
1f2a16c
refactor: 统一 typing 导入顺序并将 NoReturn 导入提前
Dt8333 Dec 11, 2025
1b564f3
refactor: 为多处函数添加返回值/参数类型注解
Dt8333 Dec 11, 2025
dc873ae
feat: 为 build_plug_list 添加 PluginInfo TypedDict 与类型注解
Dt8333 Dec 11, 2025
c0babb0
refactor: 为 display_plugins 增加参数类型注解并导入 PluginInfo
Dt8333 Dec 11, 2025
fb45af4
Merge branch 'ann-old' into chore-ann-fix
Dt8333 Dec 11, 2025
c13f5ab
style: 统一多处函数参数换行与类型注释风格
Dt8333 Dec 11, 2025
1256a66
refactor: 增强类型注解并修正 MCP 客户端与消息模型签名
Dt8333 Dec 12, 2025
ee5eb7b
fix: 统一修复 ANN 注解问题,替换 Any 为 object,完善返回类型
Dt8333 Dec 12, 2025
c5db8a4
fix: 将 KnowledgeBaseQueryTool.call 的 kwargs 标注为 object,并将 query 转为 st…
Dt8333 Dec 12, 2025
9c84007
refactor: 将多处函数参数的 Any 改为 object,统一类型注解
Dt8333 Dec 12, 2025
eda5909
fix: 让 ContentPart.__init_subclass__ 使用 Unpack[ConfigDict] 与类型检查对齐
Dt8333 Dec 17, 2025
1539a3d
refactor: 用 TypedDict+Unpack 重构 HandoffTool __init__ 参数类型
Dt8333 Dec 17, 2025
a230bbd
chore: 移除未使用的 Any 导入并整理导入依赖
Dt8333 Dec 17, 2025
3bd0555
Merge branch 'master' into chore-ann-fix
Dt8333 Dec 17, 2025
80a7e37
refactor: 使用 TypedDict+Unpack 重构 get_filtered_conversations 的 kwargs 类型
Dt8333 Dec 17, 2025
14de584
style: 在 NOT_GIVEN 与 TxResult 之间添加空行以改善可读性
Dt8333 Dec 17, 2025
8fc7f3c
fix: 兼容 Unpack 的 typing 导入
Dt8333 Dec 17, 2025
280a3ed
refactor: 将 chunk 函数改为关键字参数并加入边界处理
Dt8333 Dec 17, 2025
7f89148
fix: 调整 FixedSizeChunker.chunk 签名并实现关键字参数与边界处理
Dt8333 Dec 17, 2025
681b6d1
fix: 将 any 替换为 Any,并导入 typing 的 Any
Dt8333 Dec 17, 2025
9d0a564
fix: 更新 ToolCall.model_dump 以兼容 Pydantic v2 并移除 None 的 extra_content
Dt8333 Dec 17, 2025
4c7a16d
refactor: 统一上下文与工具类型提示为 ContextWrapper[AstrAgentContext] 与 FunctionTo…
Dt8333 Dec 17, 2025
be5e202
fix: 将 FunctionTool 的泛型由 object 改为 AstrAgentContext
Dt8333 Dec 17, 2025
3bbac61
fix: 统一 ToolExecResult 签名与输入处理,调整泛型为 AstrAgentContext
Dt8333 Dec 17, 2025
cda77fb
feat: 新增 UpdateKwargs 类型定义并完善 insert_attachment/_apply_updates 的类型注解
Dt8333 Dec 17, 2025
d6c1524
refactor: 为 RateLimiter 与 KBHelper 增加类型注解并完善返回值
Dt8333 Dec 17, 2025
74257e0
style: 为 log.py 添加参数与返回值的类型注解
Dt8333 Dec 17, 2025
61daa1e
style: 增强类型注解并规范参数签名以通过 lint
Dt8333 Dec 17, 2025
eb20e04
refactor: 使用 cast 优化上下文参数与 agent_hooks/agent_context 类型判断
Dt8333 Dec 17, 2025
21f69ee
Merge branch 'master' into chore-ann-fix
Dt8333 Jan 4, 2026
be3fcde
fix(core.provider): fix get fallback value
Dt8333 Jan 4, 2026
c15e1a7
refactor: 将 llm_response 的类型从 object 改为 LLMResponse 并导入
Dt8333 Jan 4, 2026
5a99de2
refactor: 为多处代码添加类型注解与 AsyncGenerator 返回类型
Dt8333 Jan 4, 2026
a123621
refactor: 将回调改为异步可等待并更新序列化签名及多处类型注解
Dt8333 Jan 4, 2026
cb514c6
refactor: 提升类型提示与返回类型,统一平台初始化与 webhook 签名
Dt8333 Jan 5, 2026
ea757d1
fix: 取消对 AbstractProvider 的 TypeVar 绑定,避免循环导入
Dt8333 Jan 5, 2026
8a827c2
refactor: 在 TYPE_CHECKING 时将 T 绑定为 AbstractProvider 提升类型检查
Dt8333 Jan 5, 2026
1a09de5
refactor: 为 register_star 增加泛型注解并简化 star_handler 条件
Dt8333 Jan 5, 2026
b5ce191
refactor: 为 star_handler、star_manager、updator 增加类型注解与返回类型
Dt8333 Jan 5, 2026
c2e4431
refactor: 将 PluginManager 返回类型统一为 tuple[bool, str],成功时返回空字符串
Dt8333 Jan 5, 2026
ce13afa
refactor: 为多处函数添加类型注解与返回类型
Dt8333 Jan 5, 2026
7f51e2c
refactor: 增强类型注解与函数签名,统一返回与参数类型
Dt8333 Jan 6, 2026
751ba85
Merge branch 'master' into chore-ann-fix
Dt8333 Jan 6, 2026
858db32
refactor: 去掉 **kwargs 的类型注解
Dt8333 Jan 6, 2026
5adeafc
refactor: 增强 config.py 的类型注解,添加 overload 与 Literal 支持
Dt8333 Jan 6, 2026
37b8993
refactor: 为 _expect_type 增加类型注解并导入 types,扩展 expected_type 类型
Dt8333 Jan 6, 2026
95d4db3
refactor: 为多处路由方法添加返回值类型注解
Dt8333 Jan 6, 2026
1d336a7
refactor: 统一路由返回类型为 ResponseReturnValue 并更新签名
Dt8333 Jan 6, 2026
0cd6257
Merge branch 'master' into chore-ann-fix
Dt8333 Feb 3, 2026
dca7d22
Merge branch 'master' into chore-ann-fix
Dt8333 Feb 6, 2026
2ff2de1
chore: auto fix by ruff
Dt8333 Feb 6, 2026
517bbb3
Merge branch 'chore-ann-prefix' into chore-ann-fix
Dt8333 Feb 6, 2026
4db1f6e
refactor: 统一修正返回类型注解为 None/bool 以匹配实现
Dt8333 Feb 6, 2026
8664c0a
refactor: 将 _get_next_page 改为异步并移除多余的请求错误抛出
Dt8333 Feb 6, 2026
b8485a1
Merge branch 'chore-ann-prefix' into chore-ann-fix
Dt8333 Feb 6, 2026
4061cca
fix: 本地执行传入 tool_call_timeout=None;query/session 使用 cast 提升类型安全
Dt8333 Feb 6, 2026
e0e5425
refactor: 调整多处 send_streaming 的 AsyncGenerator 泛型
Dt8333 Feb 7, 2026
a0225d7
refactor: 为 download_file、CronMessageEvent、_get_next_run_time 添加类型注解
Dt8333 Feb 7, 2026
78be2a4
refactor: 引入 NOT_GIVEN 占位符并将工具/技能参数默认值设为 NOT_GIVEN
Dt8333 Feb 7, 2026
9b946e2
refactor: 将 update_persona_folder 参数改为 NotGivenType 并默认 NOT_GIVEN
Dt8333 Feb 7, 2026
52013b4
refactor: 使用 NotGivenType 处理工具/技能默认值及父级描述字段类型
Dt8333 Feb 7, 2026
8c5ee08
Merge branch 'master' into chore-ann-fix
Dt8333 Feb 25, 2026
39f7109
Merge branch 'master' into chore-ann-fix
Dt8333 Feb 25, 2026
0e78800
Revert "refactor: 提升类型提示与返回类型,统一平台初始化与 webhook 签名"
Dt8333 Feb 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion astrbot/builtin_stars/astrbot/long_term_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, acm: AstrBotConfigManager, context: star.Context) -> None:
self.session_chats = defaultdict(list)
"""记录群成员的群聊记录"""

def cfg(self, event: AstrMessageEvent):
def cfg(self, event: AstrMessageEvent) -> dict:
cfg = self.context.get_config(umo=event.unified_msg_origin)
try:
max_cnt = int(cfg["provider_ltm_settings"]["group_message_max_cnt"])
Expand Down
7 changes: 5 additions & 2 deletions astrbot/builtin_stars/astrbot/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import traceback
from collections.abc import AsyncGenerator

from astrbot.api import star
from astrbot.api.event import AstrMessageEvent, filter
Expand All @@ -18,14 +19,16 @@ def __init__(self, context: star.Context) -> None:
except BaseException as e:
logger.error(f"聊天增强 err: {e}")

def ltm_enabled(self, event: AstrMessageEvent):
def ltm_enabled(self, event: AstrMessageEvent) -> bool:
ltmse = self.context.get_config(umo=event.unified_msg_origin)[
"provider_ltm_settings"
]
return ltmse["group_icl_enable"] or ltmse["active_reply"]["enable"]

@filter.platform_adapter_type(filter.PlatformAdapterType.ALL)
async def on_message(self, event: AstrMessageEvent):
async def on_message(
self, event: AstrMessageEvent
) -> AsyncGenerator[ProviderRequest, None]:
"""群聊记忆增强"""
has_image_or_plain = False
for comp in event.message_obj.message:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConversationCommands:
def __init__(self, context: star.Context) -> None:
self.context = context

async def _get_current_persona_id(self, session_id):
async def _get_current_persona_id(self, session_id: str) -> str | None:
curr = await self.context.conversation_manager.get_curr_conversation_id(
session_id,
)
Expand Down
2 changes: 1 addition & 1 deletion astrbot/builtin_stars/builtin_commands/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HelpCommand:
def __init__(self, context: star.Context) -> None:
self.context = context

async def _query_astrbot_notice(self):
async def _query_astrbot_notice(self) -> str:
try:
async with aiohttp.ClientSession(trust_env=True) as session:
async with session.get(
Expand Down
7 changes: 5 additions & 2 deletions astrbot/builtin_stars/builtin_commands/commands/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from astrbot.api import star
from astrbot.api.event import AstrMessageEvent, MessageEventResult
from astrbot.core.provider.entities import ProviderType
from astrbot.core.provider.provider import Provider


class ProviderCommands:
Expand All @@ -13,7 +14,7 @@ def __init__(self, context: star.Context) -> None:

def _log_reachability_failure(
self,
provider,
provider: Provider,
provider_capability_type: ProviderType | None,
err_code: str,
err_reason: str,
Expand All @@ -28,7 +29,9 @@ def _log_reachability_failure(
err_reason,
)

async def _test_provider_capability(self, provider):
async def _test_provider_capability(
self, provider: Provider
) -> tuple[bool, str | None, str | None]:
"""测试单个 provider 的可用性"""
meta = provider.meta()
provider_capability_type = meta.provider_type
Expand Down
7 changes: 6 additions & 1 deletion astrbot/builtin_stars/session_controller/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import copy
from collections.abc import AsyncGenerator
from sys import maxsize

import astrbot.api.message_components as Comp
from astrbot.api import logger
from astrbot.api.event import AstrMessageEvent, filter
from astrbot.api.star import Context, Star
from astrbot.core.message.message_event_result import MessageEventResult
from astrbot.core.provider.entities import ProviderRequest
from astrbot.core.utils.session_waiter import (
FILTERS,
USER_SESSIONS,
Expand All @@ -30,7 +33,9 @@ async def handle_session_control_agent(self, event: AstrMessageEvent) -> None:
event.stop_event()

@filter.event_message_type(filter.EventMessageType.ALL, priority=maxsize - 1)
async def handle_empty_mention(self, event: AstrMessageEvent):
async def handle_empty_mention(
self, event: AstrMessageEvent
) -> AsyncGenerator[MessageEventResult | ProviderRequest, None]:
"""实现了对只有一个 @ 的消息内容的处理"""
try:
messages = event.get_messages()
Expand Down
4 changes: 2 additions & 2 deletions astrbot/builtin_stars/web_searcher/engines/bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def __init__(self) -> None:
self.base_urls = ["https://cn.bing.com", "https://www.bing.com"]
self.headers.update({"User-Agent": USER_AGENT_BING})

def _set_selector(self, selector: str):
def _set_selector(self, selector: str) -> str:
selectors = {
"url": "div.b_attribution cite",
"title": "h2",
Expand All @@ -17,7 +17,7 @@ def _set_selector(self, selector: str):
}
return selectors[selector]

async def _get_next_page(self, query) -> str:
async def _get_next_page(self, query: str) -> str:
# if self.page == 1:
# await self._get_html(self.base_url)
for base_url in self.base_urls:
Expand Down
6 changes: 3 additions & 3 deletions astrbot/builtin_stars/web_searcher/engines/sogo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self) -> None:
self.base_url = "https://www.sogou.com"
self.headers["User-Agent"] = random.choice(USER_AGENTS)

def _set_selector(self, selector: str):
def _set_selector(self, selector: str) -> str:
selectors = {
"url": "h3 > a",
"title": "h3",
Expand All @@ -23,7 +23,7 @@ def _set_selector(self, selector: str):
}
return selectors[selector]

async def _get_next_page(self, query) -> str:
async def _get_next_page(self, query: str) -> str:
url = f"{self.base_url}/web?query={query}"
return await self._get_html(url, None)

Expand All @@ -38,7 +38,7 @@ async def search(self, query: str, num_results: int) -> list[SearchResult]:
result.url = await self._parse_url(result.url)
return results

async def _parse_url(self, url) -> str:
async def _parse_url(self, url: str) -> str:
html = await self._get_html(url)
soup = BeautifulSoup(html, "html.parser")
script = soup.find("script")
Expand Down
2 changes: 1 addition & 1 deletion astrbot/builtin_stars/web_searcher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def _process_search_result(

async def _web_search_default(
self,
query,
query: str,
num_results: int = 5,
) -> list[SearchResult]:
results = []
Expand Down
4 changes: 2 additions & 2 deletions astrbot/cli/commands/cmd_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _save_config(config: dict[str, Any]) -> None:
)


def _set_nested_item(obj: dict[str, Any], path: str, value: Any) -> None:
def _set_nested_item(obj: dict[str, Any], path: str, value: object) -> None:
"""设置嵌套字典中的值"""
parts = path.split(".")
for part in parts[:-1]:
Expand All @@ -118,7 +118,7 @@ def _set_nested_item(obj: dict[str, Any], path: str, value: Any) -> None:
obj[parts[-1]] = value


def _get_nested_item(obj: dict[str, Any], path: str) -> Any:
def _get_nested_item(obj: dict[str, Any], path: str) -> object:
"""获取嵌套字典中的值"""
parts = path.split(".")
for part in parts:
Expand Down
9 changes: 7 additions & 2 deletions astrbot/cli/commands/cmd_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import click

from ..utils import (
PluginInfo,
PluginStatus,
build_plug_list,
check_astrbot_root,
Expand All @@ -28,7 +29,11 @@ def _get_data_path() -> Path:
return (base / "data").resolve()


def display_plugins(plugins, title=None, color=None) -> None:
def display_plugins(
plugins: list[PluginInfo],
title: str | None = None,
color: int | tuple[int, int, int] | str | None = None,
) -> None:
if title:
click.echo(click.style(title, fg=color, bold=True))

Expand Down Expand Up @@ -170,7 +175,7 @@ def remove(name: str) -> None:
plugins = build_plug_list(base_path / "plugins")
plugin = next((p for p in plugins if p["name"] == name), None)

if not plugin or not plugin.get("local_path"):
if not plugin or not plugin["local_path"]:
raise click.ClickException(f"插件 {name} 不存在或未安装")

plugin_path = plugin["local_path"]
Expand Down
9 changes: 8 additions & 1 deletion astrbot/cli/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
check_dashboard,
get_astrbot_root,
)
from .plugin import PluginStatus, build_plug_list, get_git_repo, manage_plugin
from .plugin import (
PluginInfo,
PluginStatus,
build_plug_list,
get_git_repo,
manage_plugin,
)
from .version_comparator import VersionComparator

__all__ = [
"PluginInfo",
"PluginStatus",
"VersionComparator",
"build_plug_list",
Expand Down
23 changes: 17 additions & 6 deletions astrbot/cli/utils/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from enum import Enum
from io import BytesIO
from pathlib import Path
from typing import TypedDict
from zipfile import ZipFile

import click
Expand All @@ -19,6 +20,16 @@ class PluginStatus(str, Enum):
NOT_PUBLISHED = "未发布"


class PluginInfo(TypedDict):
name: str
desc: str
version: str
author: str
repo: str
status: PluginStatus
local_path: str | None


def get_git_repo(url: str, target_path: Path, proxy: str | None = None) -> None:
"""从 Git 仓库下载代码并解压到指定路径"""
temp_dir = Path(tempfile.mkdtemp())
Expand Down Expand Up @@ -102,18 +113,18 @@ def load_yaml_metadata(plugin_dir: Path) -> dict:
return {}


def build_plug_list(plugins_dir: Path) -> list:
def build_plug_list(plugins_dir: Path) -> list[PluginInfo]:
"""构建插件列表,包含本地和在线插件信息

Args:
plugins_dir (Path): 插件目录路径

Returns:
list: 包含插件信息的字典列表
list[PluginInfo]: 包含插件信息的字典列表

"""
# 获取本地插件信息
result = []
result: list[PluginInfo] = []
if plugins_dir.exists():
for plugin_name in [d.name for d in plugins_dir.glob("*") if d.is_dir()]:
plugin_dir = plugins_dir / plugin_name
Expand Down Expand Up @@ -141,7 +152,7 @@ def build_plug_list(plugins_dir: Path) -> list:
)

# 获取在线插件列表
online_plugins = []
online_plugins: list[PluginInfo] = []
try:
with httpx.Client() as client:
resp = client.get("https://api.soulter.top/astrbot/plugins")
Expand Down Expand Up @@ -191,7 +202,7 @@ def build_plug_list(plugins_dir: Path) -> list:


def manage_plugin(
plugin: dict,
plugin: PluginInfo,
plugins_dir: Path,
is_update: bool = False,
proxy: str | None = None,
Expand All @@ -209,7 +220,7 @@ def manage_plugin(
repo_url = plugin["repo"]

# 如果是更新且有本地路径,直接使用本地路径
if is_update and plugin.get("local_path"):
if is_update and plugin["local_path"]:
target_path = Path(plugin["local_path"])
else:
target_path = plugins_dir / plugin_name
Expand Down
4 changes: 2 additions & 2 deletions astrbot/cli/utils/version_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def compare_version(v1: str, v2: str) -> int:
v1 = v1.lower().replace("v", "")
v2 = v2.lower().replace("v", "")

def split_version(version):
def split_version(version: str) -> tuple[list[int], list[int | str] | None]:
match = re.match(
r"^([0-9]+(?:\.[0-9]+)*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+(.+))?$",
version,
Expand Down Expand Up @@ -77,7 +77,7 @@ def split_version(version):
return 0 # 数字部分和预发布标签都相同

@staticmethod
def _split_prerelease(prerelease):
def _split_prerelease(prerelease: str) -> list[int | str] | None:
if not prerelease:
return None
parts = prerelease.split(".")
Expand Down
22 changes: 18 additions & 4 deletions astrbot/core/agent/handoff.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
from __future__ import annotations

from collections.abc import AsyncGenerator, Awaitable, Callable
from typing import Generic

from typing_extensions import TypedDict, Unpack

from astrbot.core.message.message_event_result import MessageEventResult

from .agent import Agent
from .run_context import TContext
from .tool import FunctionTool
from .tool import FunctionTool, ParametersType


class HandoffInitKwargs(TypedDict, total=False):
handler: (
Callable[..., Awaitable[str | None] | AsyncGenerator[MessageEventResult]] | None
)
handler_module_path: str | None
active: bool


class HandoffTool(FunctionTool, Generic[TContext]):
Expand All @@ -11,11 +26,10 @@ class HandoffTool(FunctionTool, Generic[TContext]):
def __init__(
self,
agent: Agent[TContext],
parameters: dict | None = None,
parameters: ParametersType | None = None,
tool_description: str | None = None,
**kwargs,
**kwargs: Unpack[HandoffInitKwargs],
) -> None:

# Avoid passing duplicate `description` to the FunctionTool dataclass.
# Some call sites (e.g. SubAgentOrchestrator) pass `description` via kwargs
# to override what the main agent sees, while we also compute a default
Expand Down
13 changes: 10 additions & 3 deletions astrbot/core/agent/mcp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import timedelta
from typing import Generic

from mcp.types import CallToolResult
from tenacity import (
before_sleep_log,
retry,
Expand Down Expand Up @@ -322,7 +323,7 @@ async def call_tool_with_reconnect(
before_sleep=before_sleep_log(logger, logging.WARNING),
reraise=True,
)
async def _call_with_retry():
async def _call_with_retry() -> CallToolResult:
if not self.session:
raise ValueError("MCP session is not available for MCP function tools.")

Expand Down Expand Up @@ -364,7 +365,11 @@ class MCPTool(FunctionTool, Generic[TContext]):
"""A function tool that calls an MCP service."""

def __init__(
self, mcp_tool: mcp.Tool, mcp_client: MCPClient, mcp_server_name: str, **kwargs
self,
mcp_tool: mcp.Tool,
mcp_client: MCPClient,
mcp_server_name: str,
**kwargs: object,
) -> None:
super().__init__(
name=mcp_tool.name,
Expand All @@ -376,7 +381,9 @@ def __init__(
self.mcp_server_name = mcp_server_name

async def call(
self, context: ContextWrapper[TContext], **kwargs
self,
context: ContextWrapper[TContext],
**kwargs: object,
) -> mcp.types.CallToolResult:
return await self.mcp_client.call_tool_with_reconnect(
tool_name=self.mcp_tool.name,
Expand Down
Loading