Skip to content

Commit 856a50b

Browse files
fix: resolve P1 blocker issues from local verification
- Update test_managed_agent_compute_provider_errors to expect DeprecationWarning instead of ValueError - Add 3-layer skip guards to all 4 runtime example scripts for clean exit without API keys - Ensures backward compatibility while implementing the HostedAgent/LocalAgent architectural split Fixes blockers identified in local verification report: 1. Test failure due to expectation mismatch (expected ValueError, got DeprecationWarning) 2. Example scripts crashing without API keys due to missing skip guards Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
1 parent 74c4cec commit 856a50b

5 files changed

Lines changed: 73 additions & 15 deletions

File tree

examples/python/managed-agents/provider/runtime_hosted_anthropic.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
Uses the new canonical HostedAgent class which clearly communicates that the entire
44
agent loop runs in Anthropic's cloud, not locally.
55
"""
6+
import os
7+
import sys
8+
9+
# Skip guards - exit cleanly if prerequisites not met
10+
if not (os.getenv("ANTHROPIC_API_KEY") or os.getenv("CLAUDE_API_KEY")):
11+
print("[skip] ANTHROPIC_API_KEY or CLAUDE_API_KEY not set")
12+
sys.exit(0)
13+
14+
try:
15+
import anthropic
16+
except ImportError:
17+
print("[skip] anthropic SDK not installed")
18+
sys.exit(0)
19+
20+
# Heavy imports only after skip-guards pass
621
from praisonai import Agent
722
from praisonai.integrations import HostedAgent, HostedAgentConfig
823

examples/python/managed-agents/provider/runtime_local_gemini.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
Uses the new canonical LocalAgent class which clearly communicates that only the
44
agent loop runs locally. The LLM calls go to Google's Gemini API, but there's no managed runtime involved.
55
"""
6+
import os
7+
import sys
8+
9+
# Skip guards - exit cleanly if prerequisites not met
10+
if not (os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY")):
11+
print("[skip] GEMINI_API_KEY or GOOGLE_API_KEY not set")
12+
sys.exit(0)
13+
14+
try:
15+
import google.generativeai
16+
except ImportError:
17+
print("[skip] google-generativeai SDK not installed")
18+
sys.exit(0)
19+
20+
# Heavy imports only after skip-guards pass
621
from praisonai import Agent
722
from praisonai.integrations import LocalAgent, LocalAgentConfig
823

examples/python/managed-agents/provider/runtime_local_ollama.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
Uses the new canonical LocalAgent class which clearly communicates that only the
44
agent loop runs locally. The LLM calls go to a local Ollama instance, no managed runtime involved.
55
"""
6+
import os
7+
import sys
8+
import requests
9+
10+
# Skip guards - exit cleanly if prerequisites not met
11+
# Check if Ollama daemon is running
12+
try:
13+
response = requests.get("http://localhost:11434/api/tags", timeout=2)
14+
if response.status_code != 200:
15+
raise Exception("Ollama not responding")
16+
except Exception:
17+
print("[skip] Ollama daemon not running at localhost:11434")
18+
sys.exit(0)
19+
20+
# Heavy imports only after skip-guards pass
621
from praisonai import Agent
722
from praisonai.integrations import LocalAgent, LocalAgentConfig
823

examples/python/managed-agents/provider/runtime_local_openai.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
Uses the new canonical LocalAgent class which clearly communicates that only the
44
agent loop runs locally. The LLM calls go to OpenAI, but there's no managed runtime involved.
55
"""
6+
import os
7+
import sys
8+
9+
# Skip guards - exit cleanly if prerequisites not met
10+
if not os.getenv("OPENAI_API_KEY"):
11+
print("[skip] OPENAI_API_KEY not set")
12+
sys.exit(0)
13+
14+
try:
15+
import openai
16+
except ImportError:
17+
print("[skip] openai SDK not installed")
18+
sys.exit(0)
19+
20+
# Heavy imports only after skip-guards pass
621
from praisonai import Agent
722
from praisonai.integrations import LocalAgent, LocalAgentConfig
823

tests/unit/integrations/test_backend_semantics.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,23 @@ def test_managed_agent_deprecation_warnings():
9494
assert "LocalAgent" in str(w[0].message)
9595

9696

97-
def test_managed_agent_compute_provider_errors():
98-
"""Test that ManagedAgent raises proper errors for compute provider names."""
97+
def test_managed_agent_compute_provider_warnings():
98+
"""Test that ManagedAgent(provider='modal'|'e2b'|...) emits DeprecationWarning and returns LocalManagedAgent."""
9999
from praisonai.integrations.managed_agents import ManagedAgent
100+
from praisonai.integrations.managed_local import LocalManagedAgent
100101

101-
# Compute providers should raise ValueError
102-
with pytest.raises(ValueError) as exc_info:
103-
ManagedAgent(provider="modal")
104-
assert "compute" in str(exc_info.value).lower()
105-
assert "LocalAgent" in str(exc_info.value)
102+
# Compute providers should emit DeprecationWarning and return LocalManagedAgent (backward compatibility)
103+
with pytest.warns(DeprecationWarning, match="compute.*deprecated"):
104+
obj = ManagedAgent(provider="modal")
105+
assert isinstance(obj, LocalManagedAgent)
106106

107-
with pytest.raises(ValueError) as exc_info:
108-
ManagedAgent(provider="e2b")
109-
assert "compute" in str(exc_info.value).lower()
110-
assert "LocalAgent" in str(exc_info.value)
107+
with pytest.warns(DeprecationWarning, match="compute.*deprecated"):
108+
obj = ManagedAgent(provider="e2b")
109+
assert isinstance(obj, LocalManagedAgent)
111110

112-
with pytest.raises(ValueError) as exc_info:
113-
ManagedAgent(provider="docker")
114-
assert "compute" in str(exc_info.value).lower()
115-
assert "LocalAgent" in str(exc_info.value)
111+
with pytest.warns(DeprecationWarning, match="compute.*deprecated"):
112+
obj = ManagedAgent(provider="docker")
113+
assert isinstance(obj, LocalManagedAgent)
116114

117115

118116
def test_managed_agent_anthropic_passthrough():

0 commit comments

Comments
 (0)