Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 4 additions & 2 deletions examples/temporal/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Core framework dependency
mcp-agent @ file://../../ # Link to the local mcp-agent project root
mcp-agent @ file://../../ # Link to the local mcp-agent project root. Remove @ file://../../ for cloud deployment

# Additional dependencies specific to this example
temporalio
anthropic
openai
temporalio
10 changes: 3 additions & 7 deletions examples/temporal/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ class RouterWorkflow(Workflow[str]):
"""

@app.workflow_run
async def run(self, input: str) -> WorkflowResult[str]:
async def run(self) -> WorkflowResult[str]:
"""
Run the workflow, processing the input data.

Args:
input_data: The data to process
Run the workflow, routing to the correct agents.

Returns:
A WorkflowResult containing the processed data
Expand Down Expand Up @@ -81,7 +78,7 @@ async def run(self, input: str) -> WorkflowResult[str]:
# You can use any LLM with an LLMRouter
llm = OpenAIAugmentedLLM(name="openai_router", instruction="You are a router")
router = LLMRouter(
llm=llm,
llm_factory=lambda _agent: llm,
agents=[finder_agent, writer_agent, reasoning_agent],
functions=[print_to_console, print_hello_world],
context=app.context,
Expand Down Expand Up @@ -150,7 +147,6 @@ async def main():

handle = await executor.start_workflow(
"RouterWorkflow",
None,
)
a = await handle.result()
print(a)
Expand Down
7 changes: 1 addition & 6 deletions examples/temporal/run_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@
import asyncio
import logging

import workflows # noqa: F401
from main import app
from basic import SimpleWorkflow # noqa: F401
from evaluator_optimizer import EvaluatorOptimizerWorkflow # noqa: F401
from orchestrator import OrchestratorWorkflow # noqa: F401
from parallel import ParallelWorkflow # noqa: F401
from router import RouterWorkflow # noqa: F401
from interactive import WorkflowWithInteraction # noqa: F401

from mcp_agent.executor.temporal import create_temporal_worker_for_app

Expand Down
6 changes: 6 additions & 0 deletions examples/temporal/workflows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from basic import SimpleWorkflow # noqa: F401
from evaluator_optimizer import EvaluatorOptimizerWorkflow # noqa: F401
from orchestrator import OrchestratorWorkflow # noqa: F401
from parallel import ParallelWorkflow # noqa: F401
from router import RouterWorkflow # noqa: F401
from interactive import WorkflowWithInteraction # noqa: F401
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Switch to relative imports for package safety

Bare imports break when not running from the module directory. Use explicit relative imports.

-from basic import SimpleWorkflow  # noqa: F401
-from evaluator_optimizer import EvaluatorOptimizerWorkflow  # noqa: F401
-from orchestrator import OrchestratorWorkflow  # noqa: F401
-from parallel import ParallelWorkflow  # noqa: F401
-from router import RouterWorkflow  # noqa: F401
-from interactive import WorkflowWithInteraction  # noqa: F401
+from .basic import SimpleWorkflow  # noqa: F401
+from .evaluator_optimizer import EvaluatorOptimizerWorkflow  # noqa: F401
+from .orchestrator import OrchestratorWorkflow  # noqa: F401
+from .parallel import ParallelWorkflow  # noqa: F401
+from .router import RouterWorkflow  # noqa: F401
+from .interactive import WorkflowWithInteraction  # noqa: F401
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from basic import SimpleWorkflow # noqa: F401
from evaluator_optimizer import EvaluatorOptimizerWorkflow # noqa: F401
from orchestrator import OrchestratorWorkflow # noqa: F401
from parallel import ParallelWorkflow # noqa: F401
from router import RouterWorkflow # noqa: F401
from interactive import WorkflowWithInteraction # noqa: F401
from .basic import SimpleWorkflow # noqa: F401
from .evaluator_optimizer import EvaluatorOptimizerWorkflow # noqa: F401
from .orchestrator import OrchestratorWorkflow # noqa: F401
from .parallel import ParallelWorkflow # noqa: F401
from .router import RouterWorkflow # noqa: F401
from .interactive import WorkflowWithInteraction # noqa: F401
🤖 Prompt for AI Agents
In examples/temporal/workflows.py lines 1-6, the module uses bare imports which
fail when the package isn't executed from its directory; change them to explicit
relative imports (e.g. prefix each import with a single dot or appropriate
number of dots for sibling modules) so they resolve correctly when the package
is imported, and keep or adjust any linter ignores as needed.

Loading