Skip to content
Closed
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
24 changes: 16 additions & 8 deletions examples/agents/16k_credentials_google_adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,31 @@
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():
"""Create a Google ADK agent with a credential-aware tool."""
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)],
)
Expand Down
8 changes: 6 additions & 2 deletions examples/agents/39c_serverless_code_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
Loading