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

SubAgentTemplate

class SubAgentTemplate(BaseModel)
源码Source agentscope/app/_types.py:114–220

子智能体模板,承载智能体的部署、调度与服务化运行。位于 agentscope.app 包。

Developers register one or more templates at the create_app entry point. When the leader agent calls AgentCreate with a matching subagent_type, the template's configuration is used instead of the built-in defaults.

The :attr:type field serves as the routing key — it becomes an enum value of the subagent_type parameter exposed to the LLM. This is distinct from the name parameter in AgentCreate, which is the per-instance identifier the leader assigns to each worker (used for TeamSay(to=name)).

All fields are pure data (no callables), so the template is fully serializable for future config-driven startup.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
typestr
类型字段。
Field(description="Template type identifier, e.g. ``'researcher'`` or ``'coder'``. Used as the enum value for the ``subagent_type`` parameter in ``AgentCreate``.")
descriptionstr
`description` 字段。
Field(description='Agent-readable description of this sub-agent type. Exposed to the LLM in the ``AgentCreate`` tool schema so it can choose the appropriate type.')
system_prompt_templatestr
系统提示词模板字段。
Field(description="A Python format string for the worker's system prompt. Available placeholders: ``{team_name}``, ``{team_description}``, ``{member_name}``, ``{member_description}``, ``{leader_name}``.")
context_configContextConfig
上下文配置字段。
Field(default_factory=ContextConfig, description='Context configuration for the sub-agent.')
react_configReActConfig
ReAct 配置字段。
Field(default_factory=ReActConfig, description='ReAct loop configuration for the sub-agent.')
permission_contextPermissionContext
权限上下文字段。
Field(default_factory=PermissionContext, description='Permission context applied to the sub-agent at creation time. Controls what the worker is allowed to do (e.g. read-only vs. full access).')
override_leader_modebool
`override_leader_mode` 字段。
Field(default=False, description="Whether the template's :attr:`permission_context.mode` should override the leader session's mode for the worker. ``True`` — the worker runs in the template's mode (typical for templates that pin a specific posture, e.g. a read-only research worker). ``False`` (default) — the worker inherits the leader's current mode.")
extend_leader_permission_rulesbool
`extend_leader_permission_rules` 字段。
Field(default=True, description="Whether the leader session's allow/deny/ask permission rules should be merged on top of the template's. ``True`` (default) — leader rules are appended after the template's rules for each tool, so the worker doesn't re-prompt for permissions the user has already confirmed; the template's rules take precedence on evaluation order. ``False`` — the template's rules are the worker's complete rule set.")
extend_leader_working_directoriesbool
`extend_leader_working_directories` 字段。
Field(default=True, description="Whether the leader session's working directories should be merged into the template's. ``True`` (default) — leader directories are added for keys not already in the template (template wins on key collisions). ``False`` — the template's working directories are the worker's complete set.")
tasks_contextTaskContext
任务上下文字段。
Field(default_factory=TaskContext, description='Pre-defined task context for the sub-agent, allowing the template to seed an initial workflow.')

属性详情Attribute Detail

type

str = Field(description="Template type identifier, e.g. ``'researcher'`` or ``'coder'``. Used as the enum value for the ``subagent_type`` parameter in ``AgentCreate``.")

类型字段。声明为 str。

Template type identifier, e.g.

源码Source agentscope/app/_types.py:132

description

str = Field(description='Agent-readable description of this sub-agent type. Exposed to the LLM in the ``AgentCreate`` tool schema so it can choose the appropriate type.')

description 字段。声明为 str。

Agent-readable description of this sub-agent type.

源码Source agentscope/app/_types.py:140

system_prompt_template

str = Field(description="A Python format string for the worker's system prompt. Available placeholders: ``{team_name}``, ``{team_description}``, ``{member_name}``, ``{member_description}``, ``{leader_name}``.")

系统提示词模板字段。声明为 str。

A Python format string for the worker's system prompt.

源码Source agentscope/app/_types.py:148

context_config

ContextConfig = Field(default_factory=ContextConfig, description='Context configuration for the sub-agent.')

上下文配置字段。声明为 ContextConfig。

Context configuration for the sub-agent.

源码Source agentscope/app/_types.py:157

react_config

ReActConfig = Field(default_factory=ReActConfig, description='ReAct loop configuration for the sub-agent.')

ReAct 配置字段。声明为 ReActConfig。

ReAct loop configuration for the sub-agent.

源码Source agentscope/app/_types.py:162

permission_context

PermissionContext = Field(default_factory=PermissionContext, description='Permission context applied to the sub-agent at creation time. Controls what the worker is allowed to do (e.g. read-only vs. full access).')

权限上下文字段。声明为 PermissionContext。

Permission context applied to the sub-agent at creation time.

源码Source agentscope/app/_types.py:167

override_leader_mode

bool = Field(default=False, description="Whether the template's :attr:`permission_context.mode` should override the leader session's mode for the worker. ``True`` — the worker runs in the template's mode (typical for templates that pin a specific posture, e.g. a read-only research worker). ``False`` (default) — the worker inherits the leader's current mode.")

override_leader_mode 字段。声明为 bool。

Whether the template's :attr:permission_context.mode should override the leader session's mode for the worker.

源码Source agentscope/app/_types.py:176

extend_leader_permission_rules

bool = Field(default=True, description="Whether the leader session's allow/deny/ask permission rules should be merged on top of the template's. ``True`` (default) — leader rules are appended after the template's rules for each tool, so the worker doesn't re-prompt for permissions the user has already confirmed; the template's rules take precedence on evaluation order. ``False`` — the template's rules are the worker's complete rule set.")

extend_leader_permission_rules 字段。声明为 bool。

Whether the leader session's allow/deny/ask permission rules should be merged on top of the template's.

源码Source agentscope/app/_types.py:188

extend_leader_working_directories

bool = Field(default=True, description="Whether the leader session's working directories should be merged into the template's. ``True`` (default) — leader directories are added for keys not already in the template (template wins on key collisions). ``False`` — the template's working directories are the worker's complete set.")

extend_leader_working_directories 字段。声明为 bool。

Whether the leader session's working directories should be merged into the template's.

源码Source agentscope/app/_types.py:202

tasks_context

TaskContext = Field(default_factory=TaskContext, description='Pre-defined task context for the sub-agent, allowing the template to seed an initial workflow.')

任务上下文字段。声明为 TaskContext。

Pre-defined task context for the sub-agent, allowing the template to seed an initial workflow.

源码Source agentscope/app/_types.py:214
基于官方固定版本源码静态生成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.