agentscope.toolAskUser
class AskUser(ToolBase)
agentscope/tool/_builtin/_ask_user.py:166–227Ask 用户,让智能体以受控方式调用外部能力。位于 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 |
|---|---|---|---|
name | str | 名称字段。 | 'AskUser' |
description | str | `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_schema | dict[str, Any] | 输入模式字段。 | AskUserParams.model_json_schema() |
metadata_schema | dict[str, Any] | None | 元数据模式字段。 | AskUserMetadata.model_json_schema() |
is_read_only | bool | `is_read_only` 字段。 | True |
is_state_injected | bool | `is_state_injected` 字段。 | False |
is_concurrency_safe | bool | `is_concurrency_safe` 字段。 | True |
is_external_tool | bool | 是外部工具字段。 | 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.
agentscope/tool/_builtin/_ask_user.py:175description
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.
agentscope/tool/_builtin/_ask_user.py:179input_schema
dict[str, Any] = AskUserParams.model_json_schema()输入模式字段。声明为 dict[str, Any]。
The input schema field.
agentscope/tool/_builtin/_ask_user.py:201metadata_schema
dict[str, Any] | None = AskUserMetadata.model_json_schema()元数据模式字段。声明为 dict[str, Any] | None。
The metadata schema field.
agentscope/tool/_builtin/_ask_user.py:203is_read_only
bool = Trueis_read_only 字段。声明为 bool。
The is read only field.
agentscope/tool/_builtin/_ask_user.py:208is_state_injected
bool = Falseis_state_injected 字段。声明为 bool。
The is state injected field.
agentscope/tool/_builtin/_ask_user.py:209is_concurrency_safe
bool = Trueis_concurrency_safe 字段。声明为 bool。
The is concurrency safe field.
agentscope/tool/_builtin/_ask_user.py:210is_external_tool
bool = True是外部工具字段。声明为 bool。
The is external tool field.
agentscope/tool/_builtin/_ask_user.py:211方法详情Method Detail
check_permissions
async def check_permissions(tool_input: dict[str, Any], context: PermissionContext) -> PermissionDecision
检查权限。
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
tool_input | dict[str, Any] | 工具输入(类型 `dict[str, Any]`)。The tool input. |
context | PermissionContext | 上下文(类型 `PermissionContext`)。The context. |
agentscope/tool/_builtin/_ask_user.py:213–227