Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion integration_tests/_contract_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ def _find_subset_errors(expected: object, actual: object, path: str = "state") -


def _restore_agent(payload: dict[str, Any]) -> Any:
from agents import Agent, handoff
from agents import Agent, function_tool, handoff

current_agent = payload.get("current_agent")
name = (
Expand All @@ -1661,6 +1661,25 @@ def _restore_agent(payload: dict[str, Any]) -> Any:
if identity == f"{name}#2":
duplicate = Agent(name=name)
return Agent(name=name, handoffs=[handoff(duplicate)])

processed_response = payload.get("last_processed_response")
serialized_functions = (
processed_response.get("functions", []) if isinstance(processed_response, dict) else []
)
has_send_email_tool = any(
isinstance(entry, dict)
and isinstance(entry.get("tool"), dict)
and entry["tool"].get("name") == "send_email"
for entry in serialized_functions
)
if has_send_email_tool:

@function_tool(name_override="send_email")
def send_email(recipient: str) -> str:
return f"sent:{recipient}"

return Agent(name=name, tools=[send_email])

return Agent(name=name)


Expand Down
16 changes: 16 additions & 0 deletions src/agents/memory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
from .openai_conversations_session import OpenAIConversationsSession
from .openai_responses_compaction_session import OpenAIResponsesCompactionSession
from .session import (
SERVER_MANAGED_CONVERSATION_SESSION_ATTR,
OpenAIResponsesCompactionArgs,
OpenAIResponsesCompactionAwareSession,
ServerManagedConversationSession,
Session,
SessionABC,
SessionHistoryMutation,
SessionHistoryRewriteArgs,
SessionHistoryRewriteAwareSession,
apply_session_history_mutations,
is_openai_responses_compaction_aware_session,
is_server_managed_conversation_session,
is_session_history_rewrite_aware_session,
)
from .session_settings import SessionSettings
from .util import SessionInputCallback
Expand All @@ -27,7 +35,15 @@
"OpenAIResponsesCompactionSession",
"OpenAIResponsesCompactionArgs",
"OpenAIResponsesCompactionAwareSession",
"SERVER_MANAGED_CONVERSATION_SESSION_ATTR",
"SessionHistoryMutation",
"SessionHistoryRewriteArgs",
"SessionHistoryRewriteAwareSession",
"ServerManagedConversationSession",
"apply_session_history_mutations",
"is_server_managed_conversation_session",
"is_openai_responses_compaction_aware_session",
"is_session_history_rewrite_aware_session",
]


Expand Down
1 change: 1 addition & 0 deletions src/agents/memory/openai_conversations_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async def start_openai_conversations_session(openai_client: AsyncOpenAI | None =


class OpenAIConversationsSession(SessionABC):
_server_managed_conversation_session = True
session_settings: SessionSettings | None = None

def __init__(
Expand Down
Loading
Loading