基类: Generic[TContext]
这封装了你传递给Runner.run()的上下文对象。它还包含关于目前为止代理运行使用情况的信息。
注意:上下文不会传递给LLM。它们是一种向您实现的代码传递依赖项和数据的方式,例如工具函数、回调函数、钩子等。
Source code in src/agents/run_context.py
| @dataclass
class RunContextWrapper(Generic[TContext]):
"""This wraps the context object that you passed to `Runner.run()`. It also contains
information about the usage of the agent run so far.
NOTE: Contexts are not passed to the LLM. They're a way to pass dependencies and data to code
you implement, like tool functions, callbacks, hooks, etc.
"""
context: TContext
"""The context object (or None), passed by you to `Runner.run()`"""
usage: Usage = field(default_factory=Usage)
"""The usage of the agent run so far. For streamed responses, the usage will be stale until the
last chunk of the stream is processed.
"""
|
上下文
instance-attribute
上下文对象(或None),由您传递给Runner.run()
使用方式
class-attribute
instance-attribute
截至目前代理运行的使用情况。对于流式响应,在流处理的最后一块数据完成之前,使用量统计可能会不准确。