适用于 Atlas 代理引擎 的框架中立协议。
ExecutionResult
runtime_checkableclass ExecutionResult(AsyncIterable[StreamEvent], Protocol)代理执行的结果。
等待最终结果,或异步迭代流媒体事件。
用法:
# Non-streamingoutput = await agent.execute(ctx, input)
# Streamingasync for event in agent.execute(ctx, input): handle(event)BaseAgent
runtime_checkableclass BaseAgent(Protocol)代理代码与运行时之间的契约。
代理公开了一个返回 ExecutionResult 的单一 execute() 方法。调用者选择执行模式:
await agent.execute(ctx, input)以获得最终结果(JSON 风格)async for event in agent.execute(ctx, input)用于流媒体(SSE 风格)
BaseLLM
runtime_checkableclass BaseLLM(Protocol)与框架无关的 LLM 协议。
由 ToolPod 在运行时使用。
BaseExecutionCallback
runtime_checkableclass BaseExecutionCallback(Protocol)在代理执行期间用于可观测性的框架中立回调。
替换 LangChain 的 BaseCallbackHandler。 AER 注入一个实施,将节点事件转发到 OE 进行日志记录。框架适配器(例如 sdk-langgraph)从框架的原生回调系统到此协议。
优先选择对 NullExecutionCallback 进行子类化,而不是直接实现此协议 — 它为包括可选扩展(例如 on_node_suspend)在内的所有方法提供了无操作默认值,因此新方法永远不会破坏现有的实现。
NullExecutionCallback
class NullExecutionCallback()具体的基类,为所有 BaseExecutionCallback 方法提供无操作默认值。
请继承此类,而不是直接实现 BaseExecutionCallback,这样协议中添加的新方法会自动得到满足——您只需覆盖您关心的事件即可。
示例:
class MyCallback(NullExecutionCallback): def on_node_start(self, node_name, inputs, *, run_id, **kwargs): print(f"starting {node_name}")