diff --git a/examples/agents/16k_credentials_google_adk.py b/examples/agents/16k_credentials_google_adk.py index ef0415cc..7f42b3eb 100644 --- a/examples/agents/16k_credentials_google_adk.py +++ b/examples/agents/16k_credentials_google_adk.py @@ -17,6 +17,19 @@ import os from conductor.ai.agents import AgentRuntime +from settings import settings + + +# Tools must be defined at module level, not nested inside the factory below. +# Workers are dispatched to processes started with the default "spawn" method, which +# re-imports the callable by qualified name — a closure cannot be pickled that way and +# registration fails before the workflow starts. +def check_github_auth() -> str: + """Check if GitHub authentication is available.""" + token = os.environ.get("GITHUB_TOKEN", "") + if token: + return f"GitHub token is set (starts with {token[:4]}...)" + return "GitHub token is NOT set" def create_adk_agent(): @@ -24,16 +37,11 @@ def create_adk_agent(): from google.adk import Agent from google.adk.tools import FunctionTool - def check_github_auth() -> str: - """Check if GitHub authentication is available.""" - token = os.environ.get("GITHUB_TOKEN", "") - if token: - return f"GitHub token is set (starts with {token[:4]}...)" - return "GitHub token is NOT set" - agent = Agent( name="github_checker", - model="gemini-2.5-flash", + # The Conductor server runs the LLM call, so this takes the same + # "provider/model" string as every other example. + model=settings.llm_model, instruction="You check GitHub authentication status.", tools=[FunctionTool(check_github_auth)], ) diff --git a/examples/agents/39c_serverless_code_execution.py b/examples/agents/39c_serverless_code_execution.py index 7794276e..43e55939 100644 --- a/examples/agents/39c_serverless_code_execution.py +++ b/examples/agents/39c_serverless_code_execution.py @@ -64,8 +64,6 @@ def _start_mock_server(port: int = 9753) -> HTTPServer: # ── Agent setup ─────────────────────────────────────────────────────── -mock_server = _start_mock_server(port=9753) - serverless_coder = Agent( name="serverless_coder", model=settings.llm_model, @@ -84,6 +82,12 @@ def _start_mock_server(port: int = 9753) -> HTTPServer: if __name__ == "__main__": + # Started here rather than at module level: worker processes are launched with + # the default "spawn" start method, which re-imports this module in a fresh + # interpreter. A module-level start would try to bind 127.0.0.1:9753 a second + # time in every worker and fail with "Address already in use". + mock_server = _start_mock_server(port=9753) + with AgentRuntime() as runtime: print("--- Serverless Code Execution ---") result = runtime.run(