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

InjectionConfig

class InjectionConfig(BaseModel)
源码Source agentscope/agent/_config.py:195–359

AgentScope 的运行时状态注入相关配置。位于 agentscope.agent 包。

The state injection related configuration in AgentScope. Declared in agentscope.agent.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
inject_runtime_statebool
`inject_runtime_state` 字段。
Field(title='Inject Runtime State', description='Inject the runtime state to context, including current time,tasks state, context length, etc.', default=True)
timezonestr
`timezone` 字段。
Field(title='Timezone', default='UTC', description="The injected timezone. e.g. 'America/New_York' or 'Asia/Shanghai'.")
time_formatstr
时间格式字段。
Field(title='Time Format', default='%Y-%m-%dT%H:%M:%S', description="The format to inject and parse the time information, which must round-trip a full timestamp, i.e. carry the date part. A time-only format such as '%H:%M:%S' makes the parsed time fall back to year 1900, so that the time is injected in every iteration.")
time_intervalfloat
时间间隔字段。
Field(title='Time Interval', default=0.5, ge=0, description='The minimum time interval in hours from the last injection to trigger new time injection')
context_buffer_ratiofloat | None
`context_buffer_ratio` 字段。
Field(title='Context Buffer', default=None, ge=0, le=1, description="Deprecated, use the 'context_buffer_ratio' of the context config instead. When provided, it overrides the one in the context config.")
tool_retries_limitint
工具重试限制字段。
Field(title='Tool Retries Limit', default=3, ge=3, description='The number of consecutive failures of the same tool call that triggers the tool error injection.')
tool_retries_hintstr
`tool_retries_hint` 字段。
Field(title='Tool Retries Hint', default="The last {count} calls to '{tool_name}' with the same arguments all failed. Stop retrying the same call as-is, check the error message and try a different approach.", description="The hint injected when the same tool call keeps failing, where the '{tool_name}' and '{count}' placeholders will be replaced by the failing tool name and the number of consecutive failures.")
templatestr
模板字段。
Field(title='Template', default='<system-reminder>Treat the following as the ground truth at this point of the conversation. Anything stated earlier is outdated, and a later reminder, if any, supersedes this one:\n{runtime_state}\n</system-reminder>', description="The template to wrap the injected runtime state, where the '{runtime_state}' placeholder will be replaced by the injected fields.")
injection_sourcestr
`injection_source` 字段。
Field(title='Injection Source', default='{"label": "System", "sublabel": "Runtime State"}', description='The source of the injected hint block, which is also used to identify the previous injections within the context.')
task_tool_nameslist[str]
`task_tool_names` 字段。
Field(title='Task Tool Names', default_factory=lambda: ['TaskCreate', 'TaskGet', 'TaskList', 'TaskUpdate'], description='The names of the task related tools. Their presence in the context suppresses the tasks injection.')
extra_fieldsdict[str, str]
`extra_fields` 字段。
Field(title='Extra Fields', default_factory=dict, description="The extra fields to inject, which will be wrapped into the '<{key}>{value}</{key}>' format.")
emit_hint_eventbool
`emit_hint_event` 字段。
Field(title='Emit Hint Event', default=True, description='If emit the HintBlockEvent when runtime state injection happens.')

属性详情Attribute Detail

inject_runtime_state

bool = Field(title='Inject Runtime State', description='Inject the runtime state to context, including current time,tasks state, context length, etc.', default=True)

inject_runtime_state 字段。声明为 bool。

Inject the runtime state to context, including current time,tasks state, context length, etc.

源码Source agentscope/agent/_config.py:198

timezone

str = Field(title='Timezone', default='UTC', description="The injected timezone. e.g. 'America/New_York' or 'Asia/Shanghai'.")

timezone 字段。声明为 str。

The injected timezone.

源码Source agentscope/agent/_config.py:209

time_format

str = Field(title='Time Format', default='%Y-%m-%dT%H:%M:%S', description="The format to inject and parse the time information, which must round-trip a full timestamp, i.e. carry the date part. A time-only format such as '%H:%M:%S' makes the parsed time fall back to year 1900, so that the time is injected in every iteration.")

时间格式字段。声明为 str。

The format to inject and parse the time information, which must round-trip a full timestamp, i.e.

源码Source agentscope/agent/_config.py:220

time_interval

float = Field(title='Time Interval', default=0.5, ge=0, description='The minimum time interval in hours from the last injection to trigger new time injection')

时间间隔字段。声明为 float。

The minimum time interval in hours from the last injection to trigger new time injection

源码Source agentscope/agent/_config.py:234

context_buffer_ratio

float | None = Field(title='Context Buffer', default=None, ge=0, le=1, description="Deprecated, use the 'context_buffer_ratio' of the context config instead. When provided, it overrides the one in the context config.")

context_buffer_ratio 字段。声明为 float | None。

Deprecated, use the 'context_buffer_ratio' of the context config instead.

源码Source agentscope/agent/_config.py:246

tool_retries_limit

int = Field(title='Tool Retries Limit', default=3, ge=3, description='The number of consecutive failures of the same tool call that triggers the tool error injection.')

工具重试限制字段。声明为 int。

The number of consecutive failures of the same tool call that triggers the tool error injection.

源码Source agentscope/agent/_config.py:260

tool_retries_hint

str = Field(title='Tool Retries Hint', default="The last {count} calls to '{tool_name}' with the same arguments all failed. Stop retrying the same call as-is, check the error message and try a different approach.", description="The hint injected when the same tool call keeps failing, where the '{tool_name}' and '{count}' placeholders will be replaced by the failing tool name and the number of consecutive failures.")

tool_retries_hint 字段。声明为 str。

The hint injected when the same tool call keeps failing, where the '{tool_name}' and '{count}' placeholders will be replaced by the failing tool name and the number of consecutive failures.

源码Source agentscope/agent/_config.py:272

template

str = Field(title='Template', default='<system-reminder>Treat the following as the ground truth at this point of the conversation. Anything stated earlier is outdated, and a later reminder, if any, supersedes this one:\n{runtime_state}\n</system-reminder>', description="The template to wrap the injected runtime state, where the '{runtime_state}' placeholder will be replaced by the injected fields.")

模板字段。声明为 str。

The template to wrap the injected runtime state, where the '{runtime_state}' placeholder will be replaced by the injected fields.

源码Source agentscope/agent/_config.py:288

injection_source

str = Field(title='Injection Source', default='{"label": "System", "sublabel": "Runtime State"}', description='The source of the injected hint block, which is also used to identify the previous injections within the context.')

injection_source 字段。声明为 str。

The source of the injected hint block, which is also used to identify the previous injections within the context.

源码Source agentscope/agent/_config.py:315

task_tool_names

list[str] = Field(title='Task Tool Names', default_factory=lambda: ['TaskCreate', 'TaskGet', 'TaskList', 'TaskUpdate'], description='The names of the task related tools. Their presence in the context suppresses the tasks injection.')

task_tool_names 字段。声明为 list[str]。

The names of the task related tools.

源码Source agentscope/agent/_config.py:326

extra_fields

dict[str, str] = Field(title='Extra Fields', default_factory=dict, description="The extra fields to inject, which will be wrapped into the '<{key}>{value}</{key}>' format.")

extra_fields 字段。声明为 dict[str, str]。

The extra fields to inject, which will be wrapped into the ' {value} ' format.

源码Source agentscope/agent/_config.py:342

emit_hint_event

bool = Field(title='Emit Hint Event', default=True, description='If emit the HintBlockEvent when runtime state injection happens.')

emit_hint_event 字段。声明为 bool。

If emit the HintBlockEvent when runtime state injection happens.

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