From c412afe655cc4769ea02d184f2de1d0a75c2be75 Mon Sep 17 00:00:00 2001 From: Jason Yang Date: Fri, 15 Aug 2025 10:29:22 -0700 Subject: [PATCH 1/3] Adding openai fixes --- .../10_temporal/000_hello_acp/project/run_worker.py | 2 +- .../10_temporal/010_agent_chat/project/run_worker.py | 2 +- .../020_state_machine/project/run_worker.py | 2 +- .../020_state_machine/project/workflow.py | 6 +++--- pyproject.toml | 2 +- src/agentex/lib/cli/handlers/run_handlers.py | 12 +++++++----- .../lib/core/services/adk/providers/openai.py | 3 ++- uv.lock | 6 +++--- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/examples/tutorials/10_agentic/10_temporal/000_hello_acp/project/run_worker.py b/examples/tutorials/10_agentic/10_temporal/000_hello_acp/project/run_worker.py index ded5bc95..417ee95b 100644 --- a/examples/tutorials/10_agentic/10_temporal/000_hello_acp/project/run_worker.py +++ b/examples/tutorials/10_agentic/10_temporal/000_hello_acp/project/run_worker.py @@ -6,7 +6,7 @@ from agentex.lib.utils.debug import setup_debug_if_enabled from agentex.lib.environment_variables import EnvironmentVariables -from workflow import At000HelloAcpWorkflow +from project.workflow import At000HelloAcpWorkflow diff --git a/examples/tutorials/10_agentic/10_temporal/010_agent_chat/project/run_worker.py b/examples/tutorials/10_agentic/10_temporal/010_agent_chat/project/run_worker.py index cb07abf7..00a3425b 100644 --- a/examples/tutorials/10_agentic/10_temporal/010_agent_chat/project/run_worker.py +++ b/examples/tutorials/10_agentic/10_temporal/010_agent_chat/project/run_worker.py @@ -6,7 +6,7 @@ from agentex.lib.utils.debug import setup_debug_if_enabled from agentex.lib.environment_variables import EnvironmentVariables -from workflow import At010AgentChatWorkflow +from project.workflow import At010AgentChatWorkflow diff --git a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/run_worker.py b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/run_worker.py index a18fb0ce..d8ce18b6 100644 --- a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/run_worker.py +++ b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/run_worker.py @@ -6,7 +6,7 @@ from agentex.lib.utils.debug import setup_debug_if_enabled from agentex.lib.environment_variables import EnvironmentVariables -from workflow import At020StateMachineWorkflow +from project.workflow import At020StateMachineWorkflow environment_variables = EnvironmentVariables.refresh() diff --git a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflow.py b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflow.py index 209c13cf..6742fed6 100644 --- a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflow.py +++ b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflow.py @@ -13,9 +13,9 @@ from agentex.lib.sdk.state_machine.state import State from state_machines.deep_research import DeepResearchStateMachine, DeepResearchState, DeepResearchData -from workflows.deep_research.clarify_user_query import ClarifyUserQueryWorkflow -from workflows.deep_research.waiting_for_user_input import WaitingForUserInputWorkflow -from workflows.deep_research.performing_deep_research import PerformingDeepResearchWorkflow +from project.workflows.deep_research.clarify_user_query import ClarifyUserQueryWorkflow +from project.workflows.deep_research.waiting_for_user_input import WaitingForUserInputWorkflow +from project.workflows.deep_research.performing_deep_research import PerformingDeepResearchWorkflow environment_variables = EnvironmentVariables.refresh() diff --git a/pyproject.toml b/pyproject.toml index 096ce8bc..9ae4ab7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "jinja2>=3.1.3,<4", "mcp[cli]>=1.4.1", "scale-gp>=0.1.0a59", - "openai-agents>=0.0.7,!=0.2.3", # 0.2.3 bug - https://github.com/openai/openai-agents-python/issues/1276 + "openai-agents==0.2.7", # 0.2.3 bug - https://github.com/openai/openai-agents-python/issues/1276 "tzlocal>=5.3.1", "tzdata>=2025.2", "pytest>=8.4.0", diff --git a/src/agentex/lib/cli/handlers/run_handlers.py b/src/agentex/lib/cli/handlers/run_handlers.py index 30d84034..228709ad 100644 --- a/src/agentex/lib/cli/handlers/run_handlers.py +++ b/src/agentex/lib/cli/handlers/run_handlers.py @@ -89,14 +89,13 @@ async def start_temporal_worker_with_reload( worker_path: Path, env: dict[str, str], process_manager: ProcessManager, manifest_dir: Path ) -> asyncio.Task[None]: """Start temporal worker with auto-reload using watchfiles""" - try: from watchfiles import awatch except ImportError: console.print("[yellow]watchfiles not installed, falling back to basic worker start[/yellow]") console.print("[dim]Install with: pip install watchfiles[/dim]") # Fallback to regular worker without reload - worker_process = await start_temporal_worker(worker_path, env) + worker_process = await start_temporal_worker(worker_path, env, manifest_dir) process_manager.add_process(worker_process) return asyncio.create_task(stream_process_output(worker_process, "WORKER")) @@ -114,6 +113,7 @@ async def start_worker() -> asyncio.subprocess.Process: # Extract agent name from worker path for cleanup agent_name = env.get("AGENT_NAME") + console.print(f"FOUND AGENT_NAME FROM ENV VARS: {agent_name} {agent_name is None}") if agent_name is None: agent_name = worker_path.parent.parent.name @@ -150,12 +150,12 @@ async def start_worker() -> asyncio.subprocess.Process: try: # Start initial worker - await start_worker() + current_process = await start_worker() if current_process: output_task = asyncio.create_task(stream_process_output(current_process, "WORKER")) # Watch for file changes - async for changes in awatch(worker_path.parent): + async for changes in awatch(manifest_dir, recursive=True): # Filter for Python files py_changes = [(change, path) for change, path in changes if str(path).endswith('.py')] @@ -225,7 +225,9 @@ async def start_temporal_worker( worker_path: Path, env: dict[str, str], manifest_dir: Path ) -> asyncio.subprocess.Process: """Start the temporal worker process""" - cmd = [sys.executable, "-m", "run_worker"] + run_worker_target = calculate_uvicorn_target_for_local(worker_path, manifest_dir) + + cmd = [sys.executable, "-m", run_worker_target] console.print(f"[blue]Starting Temporal worker from {worker_path}...[/blue]") diff --git a/src/agentex/lib/core/services/adk/providers/openai.py b/src/agentex/lib/core/services/adk/providers/openai.py index 3393f5db..3b4e601d 100644 --- a/src/agentex/lib/core/services/adk/providers/openai.py +++ b/src/agentex/lib/core/services/adk/providers/openai.py @@ -653,10 +653,11 @@ async def run_agent_streamed_auto_send( # Handle reasoning items reasoning_item = event.item.raw_item + print(f"TRYING TO GET CONTENT OF REASONING ITEM: {reasoning_item}") reasoning_content = ReasoningContent( author="agent", summary=[summary.text for summary in reasoning_item.summary], - content=[content.text for content in reasoning_item.content] if reasoning_item.content else None, + content=[content.text for content in reasoning_item.content] if hasattr(reasoning_item, "content") else None, ) # Create reasoning content using streaming context (immediate completion) diff --git a/uv.lock b/uv.lock index 8f833e4c..0b7b7472 100644 --- a/uv.lock +++ b/uv.lock @@ -1,10 +1,10 @@ version = 1 -revision = 3 +revision = 2 requires-python = ">=3.12, <4" [[package]] name = "agentex-sdk" -version = "0.2.9" +version = "0.4.0" source = { editable = "." } dependencies = [ { name = "aiohttp" }, @@ -74,7 +74,7 @@ requires-dist = [ { name = "litellm", specifier = ">=1.66.0,<2" }, { name = "mcp", extras = ["cli"], specifier = ">=1.4.1" }, { name = "openai", specifier = ">=1.99.9" }, - { name = "openai-agents", specifier = ">=0.0.7,!=0.2.3" }, + { name = "openai-agents", specifier = "==0.2.7" }, { name = "pydantic", specifier = ">=2.0.0,<3" }, { name = "pytest", specifier = ">=8.4.0" }, { name = "pytest-asyncio", specifier = ">=1.0.0" }, From 49021ba459ced9cfca9f22e037e51ed0cbf8c2ea Mon Sep 17 00:00:00 2001 From: Jason Yang Date: Fri, 15 Aug 2025 10:35:55 -0700 Subject: [PATCH 2/3] Fix the debug --- src/agentex/lib/core/services/adk/providers/openai.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/agentex/lib/core/services/adk/providers/openai.py b/src/agentex/lib/core/services/adk/providers/openai.py index 3b4e601d..6df881ad 100644 --- a/src/agentex/lib/core/services/adk/providers/openai.py +++ b/src/agentex/lib/core/services/adk/providers/openai.py @@ -653,7 +653,6 @@ async def run_agent_streamed_auto_send( # Handle reasoning items reasoning_item = event.item.raw_item - print(f"TRYING TO GET CONTENT OF REASONING ITEM: {reasoning_item}") reasoning_content = ReasoningContent( author="agent", summary=[summary.text for summary in reasoning_item.summary], From 175317ed44e755020fc75a1eca3dc2c2fdb602d5 Mon Sep 17 00:00:00 2001 From: Jason Yang Date: Fri, 15 Aug 2025 10:38:42 -0700 Subject: [PATCH 3/3] Adding all fixes --- .../10_temporal/020_state_machine/project/workflow.py | 2 +- .../project/workflows/deep_research/clarify_user_query.py | 2 +- .../project/workflows/deep_research/performing_deep_research.py | 2 +- .../project/workflows/deep_research/waiting_for_user_input.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflow.py b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflow.py index 6742fed6..d29f4b4d 100644 --- a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflow.py +++ b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflow.py @@ -12,7 +12,7 @@ from agentex.lib.environment_variables import EnvironmentVariables from agentex.lib.sdk.state_machine.state import State -from state_machines.deep_research import DeepResearchStateMachine, DeepResearchState, DeepResearchData +from project.state_machines.deep_research import DeepResearchStateMachine, DeepResearchState, DeepResearchData from project.workflows.deep_research.clarify_user_query import ClarifyUserQueryWorkflow from project.workflows.deep_research.waiting_for_user_input import WaitingForUserInputWorkflow from project.workflows.deep_research.performing_deep_research import PerformingDeepResearchWorkflow diff --git a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/clarify_user_query.py b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/clarify_user_query.py index c00ef770..c02e2c70 100644 --- a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/clarify_user_query.py +++ b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/clarify_user_query.py @@ -6,7 +6,7 @@ from agentex.lib.types.llm_messages import LLMConfig, SystemMessage, UserMessage from agentex.lib.utils.logging import make_logger -from state_machines.deep_research import DeepResearchData, DeepResearchState +from project.state_machines.deep_research import DeepResearchData, DeepResearchState logger = make_logger(__name__) diff --git a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/performing_deep_research.py b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/performing_deep_research.py index d8afbc82..a35c0aa5 100644 --- a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/performing_deep_research.py +++ b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/performing_deep_research.py @@ -10,7 +10,7 @@ from agentex.types.text_content import TextContent from agentex.lib.utils.logging import make_logger -from state_machines.deep_research import DeepResearchData, DeepResearchState +from project.state_machines.deep_research import DeepResearchData, DeepResearchState logger = make_logger(__name__) diff --git a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/waiting_for_user_input.py b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/waiting_for_user_input.py index 94aa8924..c1a0f99d 100644 --- a/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/waiting_for_user_input.py +++ b/examples/tutorials/10_agentic/10_temporal/020_state_machine/project/workflows/deep_research/waiting_for_user_input.py @@ -2,7 +2,7 @@ from agentex.lib.sdk.state_machine import StateWorkflow, StateMachine from agentex.lib.utils.logging import make_logger from temporalio import workflow -from state_machines.deep_research import DeepResearchData, DeepResearchState +from project.state_machines.deep_research import DeepResearchData, DeepResearchState logger = make_logger(__name__)