AS AgentScopeAPI 手册 / API Reference
类class agentscope.tool

ToolChoice

class ToolChoice(BaseModel)
源码Source agentscope/tool/_types.py:178–203

工具选项配置。位于 agentscope.tool 包。

The tool choice configuration. Declared in agentscope.tool.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
modeLiteral['auto', 'none', 'required'] | str
模式字段。
The tool choice mode. Supports: * ``"auto"`` – the model decides whether to call a tool. * ``"none"`` – the model must not call any tool. * ``"required"`` – the model must call at least one tool. * ``str`` (a tool name) – the model **must** call exactly that tool (forced single-tool call). The name is validated against ``tools`` (if provided) or against the full tools list passed to the model.
—
toolslist[str] | None
工具字段。
An optional list of tool names. When specified, the tool schemas forwarded to the model are filtered to only those tools. This also acts as a validation whitelist for ``mode`` when it is a specific tool name (str): the name must appear in this list. Prefer using ``mode=<tool_name>`` (str) over ``tools=["<tool_name>"]`` when the goal is a forced single-tool call without changing the available tool set, as the former avoids schema-list changes that would invalidate prompt caches.
None

属性详情Attribute Detail

mode

Literal['auto', 'none', 'required'] | str

模式字段。声明为 Literal['auto', 'none', 'required'] | str。

The tool choice mode. Supports:

  • "auto" – the model decides whether to call a tool.
  • "none" – the model must not call any tool.
  • "required" – the model must call at least one tool.
  • str (a tool name) – the model must call exactly that tool (forced single-tool call). The name is validated against tools (if provided) or against the full tools list passed to the model.
源码Source agentscope/tool/_types.py:202

tools

list[str] | None = None

工具字段。声明为 list[str] | None。

An optional list of tool names. When specified, the tool schemas forwarded to the model are filtered to only those tools. This also acts as a validation whitelist for mode when it is a specific tool name (str): the name must appear in this list. Prefer using mode=<tool_name> (str) over tools=["<tool_name>"] when the goal is a forced single-tool call without changing the available tool set, as the former avoids schema-list changes that would invalidate prompt caches.

源码Source agentscope/tool/_types.py:203
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.