Skip to content

Commit d883fbc

Browse files
committed
initial commit
1 parent 0c4f2b9 commit d883fbc

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/agents/run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ async def run(
640640
model_responses.append(turn_result.model_response)
641641
original_input = turn_result.original_input
642642
generated_items = turn_result.generated_items
643+
context_wrapper.run_items = generated_items
643644

644645
if server_conversation_tracker is not None:
645646
server_conversation_tracker.track_server_items(turn_result.model_response)
@@ -1080,6 +1081,7 @@ async def _start_streaming(
10801081
]
10811082
streamed_result.input = turn_result.original_input
10821083
streamed_result.new_items = turn_result.generated_items
1084+
context_wrapper.run_items = turn_result.generated_items
10831085

10841086
if server_conversation_tracker is not None:
10851087
server_conversation_tracker.track_server_items(turn_result.model_response)

src/agents/run_context.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
from dataclasses import dataclass, field
2-
from typing import Any, Generic
2+
from typing import Any, Generic, TYPE_CHECKING
33

4-
from typing_extensions import TypeVar
54

5+
from typing_extensions import TypeVar
66
from .usage import Usage
77

8+
if TYPE_CHECKING:
9+
from .items import RunItem
10+
811
TContext = TypeVar("TContext", default=Any)
912

1013

14+
1115
@dataclass
1216
class RunContextWrapper(Generic[TContext]):
13-
"""This wraps the context object that you passed to `Runner.run()`. It also contains
17+
"""
18+
This wraps the context object that you passed to `Runner.run()`. It also contains
1419
information about the usage of the agent run so far.
1520
1621
NOTE: Contexts are not passed to the LLM. They're a way to pass dependencies and data to code
@@ -24,3 +29,6 @@ class RunContextWrapper(Generic[TContext]):
2429
"""The usage of the agent run so far. For streamed responses, the usage will be stale until the
2530
last chunk of the stream is processed.
2631
"""
32+
33+
run_items: list["RunItem"] = field(default_factory=list)
34+
"""The items generated by the agent so far."""

0 commit comments

Comments
 (0)