agentscope.agentInjectionConfig
class InjectionConfig(BaseModel)
agentscope/agent/_config.py:195–359AgentScope 的运行时状态注入相关配置。位于 agentscope.agent 包。
The state injection related configuration in AgentScope. Declared in agentscope.agent.
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
inject_runtime_state | bool | `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) |
timezone | str | `timezone` 字段。 | Field(title='Timezone', default='UTC', description="The injected timezone. e.g. 'America/New_York' or 'Asia/Shanghai'.") |
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.") |
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') |
context_buffer_ratio | float | 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_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.') |
tool_retries_hint | str | `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.") |
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.") |
injection_source | str | `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_names | list[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_fields | dict[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_event | bool | `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.
agentscope/agent/_config.py:198timezone
str = Field(title='Timezone', default='UTC', description="The injected timezone. e.g. 'America/New_York' or 'Asia/Shanghai'.")timezone 字段。声明为 str。
The injected timezone.
agentscope/agent/_config.py:209time_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.
agentscope/agent/_config.py:220time_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
agentscope/agent/_config.py:234context_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.
agentscope/agent/_config.py:246tool_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.
agentscope/agent/_config.py:260tool_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.
agentscope/agent/_config.py:272template
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.
agentscope/agent/_config.py:288injection_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.
agentscope/agent/_config.py:315task_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.
agentscope/agent/_config.py:326extra_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.
agentscope/agent/_config.py:342emit_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.
agentscope/agent/_config.py:353