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

AskUser

class AskUser(ToolBase)
源码Source agentscope/tool/_builtin/_ask_user.py:166–227

Ask 用户,让智能体以受控方式调用外部能力。位于 agentscope.tool 包,继承自 ToolBase。核心成员包括 check_permissions。

External by nature: only whatever is driving the agent can put a question in front of a person, so the agent yields the call and waits for the answer to come back rather than executing anything itself.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
namestr
名称字段。
'AskUser'
descriptionstr
`description` 字段。
'Asks the user multiple-choice questions to gather information, clarify ambiguity, understand preferences, make decisions, or offer choices.\n\nUse this tool when you need to ask the user questions during execution:\n1. Gather user preferences or requirements.\n2. Clarify ambiguous instructions before proceeding.\n3. Get decisions on implementation choices as you work.\n4. Offer the user a set of directions to take.\n\n## Usage rules\n- You may batch 1–4 questions in a single call; batch related questions together.\n- Each question must have 2–4 options. Option labels must be unique within a question.\n- Question texts must be unique across the batch.\n- Users will always be able to select "Other" to provide free-text input — do not add an "Other" option yourself.\n- Use `multi_select: true` only when the choices are genuinely not mutually exclusive.\n- If you recommend a specific option, place it first and append "(Recommended)" to its label.\n- The `preview` field on an option renders a side-by-side visual comparison; only use it for concrete artifacts (code snippets, ASCII mockups, config examples) where seeing the content helps the user choose. Preview is only supported for single-select questions.\n- Put whatever the user must look at to answer — a draft, a diff, an error — in `context` rather than in the question text.\n\n## What comes back\n`output` is written for you to read. The caller also returns the same answers in `ToolResultBlock.metadata`, shaped by `AskUserMetadata`, for programs that must branch on the choice rather than read prose.'
input_schemadict[str, Any]
输入模式字段。
AskUserParams.model_json_schema()
metadata_schemadict[str, Any] | None
元数据模式字段。
AskUserMetadata.model_json_schema()
is_read_onlybool
`is_read_only` 字段。
True
is_state_injectedbool
`is_state_injected` 字段。
False
is_concurrency_safebool
`is_concurrency_safe` 字段。
True
is_external_toolbool
是外部工具字段。
True

方法摘要Method Summary

方法Method说明Description
async def check_permissions(tool_input: dict[str, Any], context: PermissionContext) -> PermissionDecisionasync
检查权限。
Never asks to ask.

属性详情Attribute Detail

name

str = 'AskUser'

名称字段。声明为 str。

The name field.

源码Source agentscope/tool/_builtin/_ask_user.py:175

description

str = 'Asks the user multiple-choice questions to gather information, clarify ambiguity, understand preferences, make decisions, or offer choices.\n\nUse this tool when you need to ask the user questions during execution:\n1. Gather user preferences or requirements.\n2. Clarify ambiguous instructions before proceeding.\n3. Get decisions on implementation choices as you work.\n4. Offer the user a set of directions to take.\n\n## Usage rules\n- You may batch 1–4 questions in a single call; batch related questions together.\n- Each question must have 2–4 options. Option labels must be unique within a question.\n- Question texts must be unique across the batch.\n- Users will always be able to select "Other" to provide free-text input — do not add an "Other" option yourself.\n- Use `multi_select: true` only when the choices are genuinely not mutually exclusive.\n- If you recommend a specific option, place it first and append "(Recommended)" to its label.\n- The `preview` field on an option renders a side-by-side visual comparison; only use it for concrete artifacts (code snippets, ASCII mockups, config examples) where seeing the content helps the user choose. Preview is only supported for single-select questions.\n- Put whatever the user must look at to answer — a draft, a diff, an error — in `context` rather than in the question text.\n\n## What comes back\n`output` is written for you to read. The caller also returns the same answers in `ToolResultBlock.metadata`, shaped by `AskUserMetadata`, for programs that must branch on the choice rather than read prose.'

description 字段。声明为 str。

The description field.

源码Source agentscope/tool/_builtin/_ask_user.py:179

input_schema

dict[str, Any] = AskUserParams.model_json_schema()

输入模式字段。声明为 dict[str, Any]。

The input schema field.

源码Source agentscope/tool/_builtin/_ask_user.py:201

metadata_schema

dict[str, Any] | None = AskUserMetadata.model_json_schema()

元数据模式字段。声明为 dict[str, Any] | None。

The metadata schema field.

源码Source agentscope/tool/_builtin/_ask_user.py:203

is_read_only

bool = True

is_read_only 字段。声明为 bool。

The is read only field.

源码Source agentscope/tool/_builtin/_ask_user.py:208

is_state_injected

bool = False

is_state_injected 字段。声明为 bool。

The is state injected field.

源码Source agentscope/tool/_builtin/_ask_user.py:209

is_concurrency_safe

bool = True

is_concurrency_safe 字段。声明为 bool。

The is concurrency safe field.

源码Source agentscope/tool/_builtin/_ask_user.py:210

is_external_tool

bool = True

是外部工具字段。声明为 bool。

The is external tool field.

源码Source agentscope/tool/_builtin/_ask_user.py:211

方法详情Method Detail

check_permissions

async def check_permissions(tool_input: dict[str, Any], context: PermissionContext) -> PermissionDecision
async

检查权限。

The call is answered by the user in the first place, so a confirmation in front of it would only be a prompt about a prompt.

参数Parameters
名称Name类型Type说明Description
tool_inputdict[str, Any]工具输入(类型 `dict[str, Any]`)。The tool input.
contextPermissionContext上下文(类型 `PermissionContext`)。The context.
返回Returns PermissionDecision
返回PermissionDecision。Returns permission decision.
源码Source agentscope/tool/_builtin/_ask_user.py:213–227

继承成员Inherited Members

基于官方固定版本源码静态生成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.