Skip to content

Commit 6b00e1f

Browse files
committed
fix: restore event_queue property and 3.9‑compatible typing in ToolContext
1 parent 1a3d953 commit 6b00e1f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/agents/tool_context.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from dataclasses import dataclass, field, fields
3-
from typing import Any, Optional
3+
from typing import Any, Optional, Union
44

55
from openai.types.responses import ResponseFunctionToolCall
66

@@ -25,13 +25,21 @@ class ToolContext(RunContextWrapper[TContext]):
2525
tool_call_id: str = field(default_factory=_assert_must_pass_tool_call_id)
2626
"""The ID of the tool call."""
2727

28-
_event_queue: asyncio.Queue[Any] | None = field(default=None, init=False, repr=False)
28+
_event_queue: Optional[asyncio.Queue[Any]] = field(default=None, init=False, repr=False)
29+
30+
@property
31+
def event_queue(self) -> Optional[asyncio.Queue[Any]]:
32+
return self._event_queue
33+
34+
@event_queue.setter
35+
def event_queue(self, queue: Optional[asyncio.Queue[Any]]) -> None:
36+
self._event_queue = queue
2937

3038
@classmethod
3139
def from_agent_context(
3240
cls,
3341
context: RunContextWrapper[TContext],
34-
tool_call_id: str | int,
42+
tool_call_id: Union[str, int],
3543
tool_call: Optional[ResponseFunctionToolCall] = None,
3644
) -> "ToolContext":
3745
"""

0 commit comments

Comments
 (0)