Runtime 与推荐入口¶
普通项目优先使用 BumblehiveRuntime。它负责组合模型、工具、Skills、历史和 Agent Loop。
常用入口¶
| 接口 | 用途 |
|---|---|
RuntimeArguments |
用一组扁平参数创建 Runtime |
from_config() |
根据参数、字典或配置对象创建 Runtime |
BumblehiveRuntime.run() |
运行一次对话 |
BumblehiveRuntime.stream() |
流式接收运行事件 |
MessageHistory |
保存调用者管理的内存历史 |
AgentRunResult |
获取回答、工具、用量和错误 |
推荐使用:
async with bumblehive.from_config(config) as runtime:
result = await runtime.run("你好", history=history)
不要同时传入 history 和 session_id。
BumblehiveRuntime¶
High-level agent runtime built from BumblehiveConfig.
from_config
classmethod
¶
from_config(config: ConfigInput = None) -> BumblehiveRuntime
Create a runtime from a JSON file, mapping, config object, or defaults.
initialize_tools
async
¶
initialize_tools() -> None
Register built-ins and connect the runtime-scoped MCP servers once.
run
async
¶
run(message: UserMessage, *, config: Mapping[str, Any] | None = None, hooks: HookInput = None, history: MessageHistory | None = None, session_id: str | None = None) -> AgentRunResult
Run one conversation turn.
With neither history nor session_id, the turn is stateless.
Passing history reads and updates caller-owned in-memory history.
Passing session_id loads, recovers, and persists a managed session.
Passing both raises ValueError.
Caller-owned history is updated whenever an AgentRunResult is
returned, including model_error and max_iterations results. It
remains unchanged when the run raises an exception or is cancelled.
Do not share one MessageHistory across concurrent runs: await turns
sequentially, or use separate histories for parallel conversations.
stream ¶
stream(message: UserMessage, *, config: Mapping[str, Any] | None = None, hooks: HookInput = None, history: MessageHistory | None = None, session_id: str | None = None, max_queue_size: int = DEFAULT_STREAM_QUEUE_SIZE) -> AsyncEventStream[AgentRunResult]
Stream one turn with stateless, in-memory, or persisted history.
run_console
async
¶
run_console(message: UserMessage, *, config: Mapping[str, Any] | None = None, hooks: HookInput = None, history: MessageHistory | None = None, session_id: str | None = None, renderer: Any | None = None, max_queue_size: int = DEFAULT_STREAM_QUEUE_SIZE) -> AgentRunResult
Run and render one turn with optional conversation history.
delete_session
async
¶
delete_session(session_id: str) -> bool
Delete a persisted session and evict its cached state.