jianmu.config¶
适用对象:框架使用者 / 节点作者 / 维护者
是否必读:按需
相关模块:jianmu.node, jianmu.guard
1. 模块职责¶
jianmu.config 是配置 re-export 层,汇总了框架级配置模型、节点配置模型以及少量与约束相关的公共类型。
这里适合查两类内容:
jianmu.yaml对应的配置模型- 内置节点和预制模式使用的配置结构
2. 适合查什么¶
- 项目级配置入口:
get_config()、load_project_env() - 框架配置模型:
JianmuConfig、PathsConfig - 节点配置模型:
AgentLLMConfig、ToolExecutorConfig - 预制模式配置:
ReActConfig、PlanExecuteConfig
3. 使用建议¶
- 需要读取项目级默认配置时,优先看
get_config()和load_project_env() - 需要为节点构造结构化配置时,优先使用这里公开的
*Config - 如果只是使用现成节点,不必先理解全部配置模型
4. 注意事项¶
- 这里公开的是稳定配置入口,不代表所有底层字段都适合作为外部协议长期依赖
Constraints的 canonical path 是jianmu.config.constraints.Constraints
5. 最小示例¶
from jianmu.config import AgentLLMConfig, ReActConfig, get_config
project_config = get_config()
react_config = ReActConfig(model="gpt-4.1-mini")
llm_config = AgentLLMConfig(temperature=0.2)
6. 常见入口¶
- 想读项目级配置:看
get_config() - 想加载
.env/ 项目环境:看load_project_env() - 想给节点传结构化配置:看
AgentLLMConfig、ToolExecutorConfig、ReActConfig
7. API 参考¶
config
¶
Jianmu configuration package.
Constraints
dataclass
¶
Constraints(
*,
guard: GuardConstraints | dict[str, Any] | None = None,
execution: ExecutionConstraints
| dict[str, Any]
| None = None,
timeout: float | None = None,
max_iterations: int | None = None,
max_messages: int | None = None,
)
High-level runtime constraints shared across guard and execution layers.
max_iterations caps the main agent/react loop rounds when a node
exposes iterative planning/execution behaviour.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
guard |
GuardConstraints
|
Guard-layer constraints applied to approvals and policy checks. |
execution |
ExecutionConstraints
|
Execution-layer constraints applied to tool/runtime sandboxes. |
timeout |
Optional[float]
|
Optional end-to-end timeout in seconds. |
max_iterations |
Optional[int]
|
Optional cap for iterative agent or ReAct loops. |
max_messages |
Optional[int]
|
Optional cap for retained message history. |
源代码位于: jianmu/config/constraints.py
from_dict
classmethod
¶
Build constraints from the canonical nested dictionary structure.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
data
|
dict[str, Any] | None
|
Canonical nested constraints dictionary. |
必需 |
返回:
| 类型 | 描述 |
|---|---|
'Constraints'
|
Parsed |
源代码位于: jianmu/config/constraints.py
coerce
classmethod
¶
Coerce arbitrary input into a Constraints instance.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
data
|
Any | None
|
Arbitrary value to coerce into constraints. |
必需 |
返回:
| 类型 | 描述 |
|---|---|
'Constraints | None'
|
Constraints instance, or |
源代码位于: jianmu/config/constraints.py
to_dict
¶
Serialize constraints to the nested canonical structure.
返回:
| 类型 | 描述 |
|---|---|
dict[str, Any]
|
Dictionary representation of the constraints object. |
JianmuConfig
¶
Bases: BaseModel
Project-level project configuration root.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
paths |
PathsConfig
|
File-system paths used by the project. |
models |
ModelsConfig
|
Model-name defaults for different workflows. |
llm |
LLMDefaultsConfig
|
Shared LLM sampling and timeout defaults. |
limits |
LimitsConfig
|
Cross-cutting operational limits. |
prompt |
PromptConfig
|
Prompt-template and bootstrap defaults. |
logging |
LoggingConfig
|
Logging behavior defaults. |
trace |
TraceConfig
|
Telemetry and trace emission defaults. |
provider_limits |
ProviderLimitsConfig
|
Provider concurrency defaults. |
execution |
ExecutionConfig
|
Tool execution backend defaults. |
guard |
GuardConfig
|
Project-level tool permission defaults. |
runtime |
RuntimeConfig
|
Reactive runner scheduling defaults. |
rag |
RagConfig
|
Retrieval-augmented generation defaults. |
PathsConfig
¶
Bases: BaseModel
File path configuration.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
outputs_dir |
str
|
Root output directory used for generated artifacts. |
store |
str
|
Default state/message store file path. |
knowledge_db |
str
|
Default SQLite database path for knowledge or RAG data. |
checkpoints_dir |
str
|
Directory used to persist runtime checkpoints. |
sandbox_config |
Optional[str]
|
Reserved for future use. |
agents_dir |
Optional[str]
|
Reserved for future use. |
workflows_dir |
Optional[str]
|
Reserved for future use. |
prompts_dir |
Optional[str]
|
Reserved for future use. |
skills_dir |
Optional[str]
|
Optional directory containing custom skills. |
ModelsConfig
¶
Bases: BaseModel
Configuration settings for LLM models used by different components of Jianmu.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
default |
str
|
Default model name for general-purpose generation. |
fallback |
str
|
Reserved for future use. |
react |
str
|
Default model for ReAct-based nodes. |
plan_execute |
str
|
Default model for plan-execute workflows. |
evaluate |
str
|
Default model for evaluator or reviewer nodes. |
LLMDefaultsConfig
¶
Bases: BaseModel
Default hyperparameter settings for LLM interactions in the system.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
temperature |
float
|
Default sampling temperature. |
top_p |
float
|
Default nucleus-sampling cutoff. |
top_k |
int
|
Default top-k sampling cutoff. |
timeout |
float
|
Default request timeout in seconds. |
max_tokens |
Optional[int]
|
Optional default completion-token limit. |
max_budget_tokens |
Optional[int]
|
Optional budget limit aggregated across one run. |
max_retries |
int
|
Default retry count for model calls. |
LimitsConfig
¶
Bases: BaseModel
Limits and threshold configurations for execution steps and memory storage.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
max_rounds |
int
|
Default maximum rounds for plan-execute loops. |
max_iterations |
int
|
Default maximum iterations for ReAct loops. |
history_limit |
int
|
Default maximum number of messages kept in history windows. |
memory_top_k |
int
|
Default number of memory items retrieved per query. |
chunk_size |
int
|
Default text chunk size for indexing or splitting. |
chunk_overlap |
int
|
Default overlap between adjacent chunks. |
rerank_alpha |
float
|
Default hybrid-search weighting factor. |
PromptConfig
¶
Bases: BaseModel
Static prompt defaults.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
persona_default_prompt |
Optional[str]
|
Optional default persona/base prompt shared by context presets. |
react_default_prompt |
Optional[str]
|
Legacy combined ReAct prompt override. |
react_protocol_prompt |
Optional[str]
|
Optional reusable protocol-only prompt fragment shared by ReAct-like execution paths. |
react_soft_landing_prompt |
Optional[str]
|
Optional final-answer prompt fragment used by ReAct soft-landing fallback when execution budget is exhausted. |
plan_execute_plan_prompt |
Optional[str]
|
Optional default planning prompt template. |
plan_execute_execute_prompt |
Optional[str]
|
Optional default execution prompt template. |
plan_execute_review_prompt |
Optional[str]
|
Optional default review prompt template. |
tools_prompt_template |
Optional[str]
|
Optional template wrapping the rendered tool description block. |
history_semantics_prompt |
Optional[str]
|
Optional prompt explaining normalized tool planning and observation history semantics. |
history_self_tool_plan_text |
Optional[str]
|
Optional rewritten content for prior assistant tool-plan messages. |
history_tool_observation_note |
Optional[str]
|
Optional rewritten note for prior tool observation messages. |
skill_capability_policy_prompt |
Optional[str]
|
Optional prompt describing skill capability semantics. |
skill_on_demand_policy_prompt |
Optional[str]
|
Optional prompt describing lazy skill loading behavior. |
skill_fallback_policy_prompt |
Optional[str]
|
Optional prompt describing fallback skill injection behavior. |
skill_resource_usage_policy_prompt |
Optional[str]
|
Optional prompt describing runtime skill resource usage. |
active_skills_header |
Optional[str]
|
Optional heading for inlined active skill blocks. |
skill_detail_heading_template |
Optional[str]
|
Optional template for one inlined skill detail block. |
skill_resources_heading_template |
Optional[str]
|
Optional template for one skill resource heading. |
skill_workdir_label |
Optional[str]
|
Optional label template for skill working directory display. |
skill_root_label |
Optional[str]
|
Optional label template for skill root display. |
skill_file_label |
Optional[str]
|
Optional label template for a single skill file. |
skill_files_label |
Optional[str]
|
Optional label template for multiple skill files. |
skills_index_heading |
Optional[str]
|
Optional heading template for the skill summary index block. |
skills_list_heading |
Optional[str]
|
Optional heading template for a non-indexed skill list block. |
skills_list_footer |
Optional[str]
|
Optional footer used beneath non-indexed skill lists. |
skill_instructions_heading |
Optional[str]
|
Optional heading template for fully inlined skill instructions. |
bt_skill_summary_hint_template |
Optional[str]
|
Optional template describing how to invoke a BT skill from summaries. |
prompt_skill_summary_hint |
Optional[str]
|
Optional hint describing prompt-skill behavior in summaries. |
skill_summary_line_template |
Optional[str]
|
Optional template for one skill summary line. |
bootstrap_files |
list[str]
|
Workspace files summarized into prompt bootstrap context. |
LoggingConfig
¶
Bases: BaseModel
Configuration settings for logging level and terminal colorization.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
level |
str
|
Default logger level name. |
colorize |
bool
|
Whether terminal logs should include ANSI colors. |
TraceConfig
¶
Bases: BaseModel
Settings for trace logging, telemetry events, and routing protocols.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
log_events |
bool
|
Whether trace events are mirrored to logs. |
safe_mode |
bool
|
Whether telemetry payloads should be sanitized conservatively. |
sample_rate |
float
|
Default sampling rate for trace emission. |
token_sample_rate |
float
|
Sampling rate applied specifically to token events. |
max_per_sec |
int
|
Per-trace/per-agent emission rate limit. |
event_sample_rates |
dict[str, float]
|
Per-event sampling overrides. |
always_events |
list[str]
|
Event names that bypass normal sampling. |
router |
Optional[str]
|
Optional trace router URI such as a file sink. |
ProviderLimitsConfig
¶
Bases: BaseModel
Provider concurrency defaults.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
openai_max_concurrency |
Optional[int]
|
Default max concurrent requests for OpenAI-compatible providers. |
litellm_max_concurrency |
Optional[int]
|
Default max concurrent requests for LiteLLM providers. |
ExecutionDockerConfig
¶
Bases: BaseModel
Docker-backed tool execution defaults.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
image |
str
|
Default Docker image used for sandboxed execution. |
timeout |
float
|
Default Docker job timeout in seconds. |
network |
str
|
Default Docker network mode. |
memory |
Optional[str]
|
Optional Docker memory limit. |
cpus |
Optional[float]
|
Optional Docker CPU limit. |
reuse_container |
bool
|
Whether tool discovery and execution should reuse one
long-lived helper container via |
env_allowlist |
list[str]
|
Explicit environment variable names passed into containers. |
env_allowprefix |
list[str]
|
Environment variable prefixes allowed into containers. |
ExecutionConfig
¶
Bases: BaseModel
Configuration options for executing commands, tools, and Docker sandbox settings.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
max_retries |
int
|
Default retry count for tool execution. |
retry_backoff |
float
|
Default delay in seconds between tool retry attempts. |
timeout_s |
float | None
|
Default timeout in seconds for one tool execution. |
tool_runner |
str
|
Default tool execution backend name. |
confirm_default |
str
|
Default confirmation mode for guarded execution. |
tool_args_max |
Optional[int]
|
Optional maximum serialized tool-argument size. |
docker |
ExecutionDockerConfig
|
Docker-specific execution defaults. |
RuntimeCheckpointConfig
¶
Bases: BaseModel
Runtime checkpoint behavior defaults.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
enabled |
bool
|
Whether runners should use a config-derived default checkpointer when one is not passed explicitly. |
backend |
str
|
Default checkpoint backend name. |
interval |
int
|
Default tick interval between checkpoint saves. |
RuntimeConfig
¶
Bases: BaseModel
Reactive runner scheduling defaults.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
max_fps |
float
|
Maximum runner tick frequency. |
max_pending_wakeups |
int
|
Maximum queued wake-up signals for async runners. |
hot_loop_warn_factor |
float
|
Threshold multiplier used to warn about hot loops. |
checkpoint |
'RuntimeCheckpointConfig'
|
Runtime checkpoint behavior defaults. |
RagEmbeddingConfig
¶
Bases: BaseModel
Configuration for RAG embedding models and API endpoint locations.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
provider |
str
|
Embedding provider name. |
model |
Optional[str]
|
Optional embedding model identifier. |
base_url |
Optional[str]
|
Optional custom API base URL. |
RagConfig
¶
Bases: BaseModel
Root configurations for Retrieval Augmented Generation (RAG) components.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
embedding |
RagEmbeddingConfig
|
Embedding-provider defaults used by RAG components. |
StateKeys
¶
Bases: BaseModel
Single source of truth for state field naming conventions.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
messages |
str
|
State key for conversation history. |
rounds |
str
|
State key for loop round counters. |
actions |
str
|
State key for model-emitted actions or tool calls. |
done |
str
|
State key indicating workflow completion. |
text_output |
str
|
State key for latest plain-text node output. |
final_answer |
str
|
State key for final user-facing answer text. |
skill_result |
str
|
State key for structured skill outputs. |
usage |
str
|
State key for aggregated model-usage metadata. |
streaming_output |
str
|
State key for incremental streamed text. |
tool_effects |
str
|
State key for aggregated tool-side-effect counters. |
EvaluationStateKeys
¶
Bases: BaseModel
State field routing for EvaluationNode outputs.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
score |
str | None
|
State key receiving the evaluator score. |
reflection |
str | None
|
State key receiving the evaluator reflection text. |
highest_score |
str | None
|
State key tracking the best score so far. |
best_answer |
str | None
|
State key storing the best answer content. |
best_answer_source |
str
|
State key pointing to the answer candidate being scored. |
AgentLLMConfig
¶
Bases: BaseModel
LLM generation parameters plus state routing keys.
system_prompt configures the persona/base prompt. Context presets may
still append protocol, tools, skills, history, and other runtime blocks.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
model |
str
|
Primary model identifier used for inference. |
temperature |
float
|
Sampling temperature for generation. |
max_tokens |
Optional[int]
|
Optional output-token cap. |
top_p |
Optional[float]
|
Optional nucleus-sampling parameter. |
top_k |
Optional[int]
|
Optional top-k sampling parameter. |
timeout |
float
|
Provider timeout in seconds. |
stream |
bool
|
Whether streaming responses are requested. |
max_budget_tokens |
Optional[int]
|
Optional budget cap shared with runtime accounting. |
resilience |
ModelResilienceConfig
|
Retry and fallback policy for provider calls. |
extra_params |
Dict[str, Any]
|
Additional provider-specific generation parameters. |
system_prompt |
Optional[str]
|
Optional persona/base prompt override. |
keys |
StateKeys
|
State-key mapping used by the node. |
ModelResilienceConfig
¶
Bases: BaseModel
Framework-level retry/fallback policy for one model call path.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
max_retries |
int
|
Maximum retry count for a single model call. |
fallback_model |
Optional[str]
|
Optional fallback model used after retries fail. |
enable_fallback |
bool
|
Whether fallback model routing is enabled. |
ReActConfig
¶
Bases: BaseModel
ReAct (Reason + Act) loop configuration.
system_prompt configures the persona/base prompt. The ReAct protocol
prompt and tool descriptions are added by the context builder.
max_iterations is the main agent-loop round limit, not a low-level
tree tick limit.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
model |
str
|
Primary model identifier used for ReAct turns. |
temperature |
float
|
Sampling temperature for generation. |
max_tokens |
Optional[int]
|
Optional output-token cap. |
top_p |
Optional[float]
|
Optional nucleus-sampling parameter. |
top_k |
Optional[int]
|
Optional top-k sampling parameter. |
timeout |
float
|
Provider timeout in seconds. |
stream |
bool
|
Whether streaming responses are requested. |
max_budget_tokens |
Optional[int]
|
Optional budget cap shared with runtime accounting. |
max_iterations |
int
|
Main ReAct loop round limit. |
soft_landing |
bool
|
Whether soft-landing summary behavior is enabled. |
resilience |
ModelResilienceConfig
|
Retry and fallback policy for provider calls. |
system_prompt |
Optional[str]
|
Optional persona/base prompt override. |
tool_choice |
Optional[Any]
|
Provider-specific tool selection directive applied only to the first model round of each ReAct run. |
extra_params |
Dict[str, Any]
|
Additional provider-specific generation parameters. |
keys |
StateKeys
|
State-key mapping used by the preset. |
SkillNodeConfig
¶
Bases: BaseModel
Configuration options specifically for skill-execution nodes in Jianmu.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
push_to_chat |
bool | None
|
Whether skill outputs should be appended to chat history. |
use_history |
bool
|
Whether prior message history is included in skill runs. |
history_limit |
int | None
|
Optional cap on retained history for skill prompting. |
react_config |
Optional[ReActConfig]
|
Optional ReAct configuration for nested skill execution. |
constraints |
Optional[Constraints]
|
Optional runtime and guard constraints for the skill node. |
skill_prompt_mode |
Literal['summary', 'full']
|
Prompt rendering mode for skills. |
keys |
StateKeys
|
State-key mapping used by the node. |
ToolExecutorConfig
¶
Bases: BaseModel
Tool executor configuration.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
max_retries |
int
|
Maximum retry count for tool execution failures. |
retry_backoff |
float
|
Backoff delay between retries. |
timeout_s |
float | None
|
Optional timeout in seconds for each tool execution. |
observation_format |
str
|
Format used for tool observations. |
execution_mode |
Literal['auto', 'serial', 'parallel']
|
Tool scheduling mode: auto, serial, or parallel. |
keys |
StateKeys
|
State-key mapping used by the executor. |
PlanExecuteConfig
¶
Bases: BaseModel
Plan-Execute(-Review) loop configuration.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
model |
str
|
Primary model identifier used across the preset. |
temperature |
float
|
Sampling temperature for generation. |
max_tokens |
Optional[int]
|
Optional output-token cap. |
top_p |
Optional[float]
|
Optional nucleus-sampling parameter. |
top_k |
Optional[int]
|
Optional top-k sampling parameter. |
timeout |
float
|
Provider timeout in seconds. |
max_budget_tokens |
Optional[int]
|
Optional budget cap shared with runtime accounting. |
stream |
bool
|
Whether streaming responses are requested. |
max_rounds |
int
|
Maximum plan/execute rounds before termination. |
enable_review |
bool
|
Whether review steps are enabled. |
review_threshold |
float
|
Score threshold for successful review. |
plan_prompt |
Optional[str]
|
Optional custom planning prompt override. |
execute_prompt |
Optional[str]
|
Optional custom execution prompt override. |
review_prompt |
Optional[str]
|
Optional custom review prompt override. |
plan_key |
str
|
State key used to store the plan. |
score_key |
str
|
State key used to store review scores. |
keys |
StateKeys
|
State-key mapping used by the preset. |
bootstrap_project
¶
bootstrap_project(
config: JianmuConfig | None = None,
root: str | Path | None = None,
) -> JianmuConfig
Load environment variables and apply logging for a project config.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
config
|
JianmuConfig | None
|
Configuration object for the operation. |
None
|
root
|
str | Path | None
|
Root path used for resolution. |
None
|
返回:
| 类型 | 描述 |
|---|---|
JianmuConfig
|
The resulting |
源代码位于: jianmu/config/loader.py
configure_logging_from_config
¶
Apply logging settings from config when telemetry is available.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
config
|
JianmuConfig
|
Configuration object for the operation. |
必需 |
源代码位于: jianmu/config/loader.py
get_config
¶
Load and cache the project configuration.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
reload
|
bool
|
Whether to force a fresh load from disk. |
False
|
root
|
str | Path | None
|
Optional project root or config file path. |
None
|
返回:
| 类型 | 描述 |
|---|---|
JianmuConfig
|
Resolved project configuration with absolute paths applied. |
引发:
| 类型 | 描述 |
|---|---|
FileNotFoundError
|
If a root path is specified but no config file is found. |
源代码位于: jianmu/config/loader.py
load_project_env
¶
Load .env from the target project root into os.environ.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
root
|
str | Path | None
|
Root path used for resolution. |
None
|
override
|
bool
|
The |
False
|
返回:
| 类型 | 描述 |
|---|---|
Path
|
The resulting |