diff --git a/examples/agno/python/examples/multi_peer_example.py b/examples/agno/python/examples/multi_peer_example.py index fa882b4d..21d80edd 100644 --- a/examples/agno/python/examples/multi_peer_example.py +++ b/examples/agno/python/examples/multi_peer_example.py @@ -9,8 +9,7 @@ A realistic multi-agent scenario using Agno's patterns: Environment Variables: OPENAI_API_KEY or LLM_OPENAI_API_KEY: OpenAI API key - HONCHO_ENVIRONMENT: 'local' or 'production' (default: production) - HONCHO_API_KEY: Required for production environment + HONCHO_API_KEY: Required for Honcho API access """ import os @@ -27,11 +26,11 @@ from honcho_agno import HonchoTools load_dotenv() -if not os.getenv("OPENAI_API_KEY") and os.getenv("LLM_OPENAI_API_KEY"): - os.environ["OPENAI_API_KEY"] = os.getenv("LLM_OPENAI_API_KEY") +if not os.getenv("OPENAI_API_KEY") and (llm_key := os.getenv("LLM_OPENAI_API_KEY")): + os.environ["OPENAI_API_KEY"] = llm_key -def create_advisor_system(honcho_env: str, session_id: str): +def create_advisor_system(session_id: str): """ Creates a multi-agent advisory system where: - Each specialist agent has its own identity (HonchoTools) @@ -41,7 +40,7 @@ def create_advisor_system(honcho_env: str, session_id: str): model_id = os.getenv("OPENAI_MODEL", "gpt-4o") # Shared Honcho client and session - honcho = Honcho(workspace_id="advisory-system", environment=honcho_env) + honcho = Honcho(workspace_id="advisory-system") session = honcho.session(session_id) user_peer = honcho.peer("user") @@ -52,7 +51,6 @@ def create_advisor_system(honcho_env: str, session_id: str): app_id="advisory-system", peer_id="tech-specialist", session_id=session_id, - environment=honcho_env, honcho_client=honcho, ) @@ -73,7 +71,6 @@ def create_advisor_system(honcho_env: str, session_id: str): app_id="advisory-system", peer_id="business-specialist", session_id=session_id, - environment=honcho_env, honcho_client=honcho, ) @@ -106,7 +103,7 @@ def create_advisor_system(honcho_env: str, session_id: str): Technical specialist's response. """ response = tech_agent.run(question) - return response.content + return str(response.content) if response.content else "" @tool def consult_business_specialist(question: str) -> str: @@ -121,14 +118,13 @@ def create_advisor_system(honcho_env: str, session_id: str): Business specialist's response. """ response = business_agent.run(question) - return response.content + return str(response.content) if response.content else "" # Coordinator has its own identity too coordinator_tools = HonchoTools( app_id="advisory-system", peer_id="coordinator", session_id=session_id, - environment=honcho_env, honcho_client=honcho, ) @@ -150,13 +146,12 @@ def create_advisor_system(honcho_env: str, session_id: str): def main(test_mode: bool = False): - honcho_env = os.getenv("HONCHO_ENVIRONMENT", "production") session_id = f"advisory-{uuid.uuid4().hex[:8]}" print(f"Session: {session_id}") print("=" * 60) - coordinator, session, user_peer = create_advisor_system(honcho_env, session_id) + coordinator, session, user_peer = create_advisor_system(session_id) if test_mode: # Non-interactive test diff --git a/examples/agno/python/examples/multi_tool_example.py b/examples/agno/python/examples/multi_tool_example.py index a9e0ea8f..2f3899d1 100644 --- a/examples/agno/python/examples/multi_tool_example.py +++ b/examples/agno/python/examples/multi_tool_example.py @@ -15,8 +15,7 @@ Pattern: toolkit = agent identity Environment Variables: OPENAI_API_KEY or LLM_OPENAI_API_KEY: OpenAI API key OPENAI_MODEL: Model to use (default: gpt-4o) - HONCHO_ENVIRONMENT: 'local' or 'production' (default: production) - HONCHO_API_KEY: Required for production environment + HONCHO_API_KEY: Required for Honcho API access """ import os @@ -32,8 +31,8 @@ from honcho_agno import HonchoTools load_dotenv() # Support both OPENAI_API_KEY and LLM_OPENAI_API_KEY -if not os.getenv("OPENAI_API_KEY") and os.getenv("LLM_OPENAI_API_KEY"): - os.environ["OPENAI_API_KEY"] = os.getenv("LLM_OPENAI_API_KEY") +if not os.getenv("OPENAI_API_KEY") and (llm_key := os.getenv("LLM_OPENAI_API_KEY")): + os.environ["OPENAI_API_KEY"] = llm_key def main(): @@ -41,14 +40,8 @@ def main(): print("HONCHO TOOLS + AGNO EXAMPLE") print("=" * 70 + "\n") - # Get environment settings - honcho_env = os.getenv("HONCHO_ENVIRONMENT", "production") - # Initialize Honcho for managing the session and user peer - honcho = Honcho( - workspace_id="travel-app", - environment=honcho_env, - ) + honcho = Honcho(workspace_id="travel-app") session = honcho.session("trip-planning-session") user_peer = honcho.peer("traveler-42") @@ -57,7 +50,6 @@ def main(): app_id="travel-app", peer_id="travel-assistant", # The toolkit speaks as "travel-assistant" session_id="trip-planning-session", - environment=honcho_env, honcho_client=honcho, ) diff --git a/examples/agno/python/examples/simple_example.py b/examples/agno/python/examples/simple_example.py index 2ee4aad1..a0f396d1 100644 --- a/examples/agno/python/examples/simple_example.py +++ b/examples/agno/python/examples/simple_example.py @@ -3,8 +3,7 @@ Simple Honcho + Agno Example Environment Variables: OPENAI_API_KEY or LLM_OPENAI_API_KEY: OpenAI API key - HONCHO_ENVIRONMENT: 'local' or 'production' (default: production) - HONCHO_API_KEY: Required for production environment + HONCHO_API_KEY: Required for Honcho API access """ import os @@ -21,22 +20,16 @@ from honcho_agno import HonchoTools load_dotenv() # Support both OPENAI_API_KEY and LLM_OPENAI_API_KEY -if not os.getenv("OPENAI_API_KEY") and os.getenv("LLM_OPENAI_API_KEY"): - os.environ["OPENAI_API_KEY"] = os.getenv("LLM_OPENAI_API_KEY") +if not os.getenv("OPENAI_API_KEY") and (llm_key := os.getenv("LLM_OPENAI_API_KEY")): + os.environ["OPENAI_API_KEY"] = llm_key def main(): - # Get environment settings - honcho_env = os.getenv("HONCHO_ENVIRONMENT", "production") - # Create shared session session_id = f"simple-{uuid.uuid4().hex[:8]}" # Initialize Honcho directly for managing user messages - honcho = Honcho( - workspace_id="agno-demo", - environment=honcho_env, - ) + honcho = Honcho(workspace_id="agno-demo") session = honcho.session(session_id) user_peer = honcho.peer("user") @@ -45,7 +38,6 @@ def main(): app_id="agno-demo", peer_id="assistant", # The toolkit speaks as "assistant" session_id=session_id, # Same session as user - environment=honcho_env, honcho_client=honcho, # Reuse client ) @@ -89,6 +81,4 @@ def main(): if __name__ == "__main__": - import sys - # Run directly - test mode is default for non-interactive execution main() diff --git a/examples/agno/python/src/honcho_agno/tools.py b/examples/agno/python/src/honcho_agno/tools.py index 60c07a86..204d3ae4 100644 --- a/examples/agno/python/src/honcho_agno/tools.py +++ b/examples/agno/python/src/honcho_agno/tools.py @@ -12,11 +12,15 @@ directly to manage other peers. import logging import uuid -from typing import Any, Literal +from typing import TYPE_CHECKING, Any from agno.tools import Toolkit from honcho import Honcho +if TYPE_CHECKING: + from honcho.peer import Peer + from honcho.session import Session + logger = logging.getLogger(__name__) @@ -60,7 +64,6 @@ class HonchoTools(Toolkit): session_id: str | None = None, api_key: str | None = None, base_url: str | None = None, - environment: Literal["local", "production"] | None = "production", honcho_client: Honcho | None = None, ) -> None: """ @@ -78,8 +81,6 @@ class HonchoTools(Toolkit): api_key: Optional API key for Honcho. If not provided, will attempt to read from HONCHO_API_KEY environment variable. base_url: Optional base URL for the Honcho API. - environment: Environment to use. Options: "local", "production". - Defaults to "production". honcho_client: Optional pre-configured Honcho client instance. If provided, other connection parameters are ignored. """ @@ -95,8 +96,6 @@ class HonchoTools(Toolkit): client_kwargs["api_key"] = api_key if base_url is not None: client_kwargs["base_url"] = base_url - if environment is not None: - client_kwargs["environment"] = environment self.honcho = Honcho(**client_kwargs) # Store identifiers