Files
praisonai-triage-agent[bot]andMervin Praison d6c367f321 fix: ManagedAgent provider overload conflates hosted-runtime vs LLM-routing (#1550)
* fix: ManagedAgent(provider=) overload conflates hosted-runtime vs LLM-routing — propose HostedAgent / LocalAgent split (fixes #1549)

- Create new HostedAgent class for hosted runtimes (Anthropic managed infrastructure)
- Create new LocalAgent class for local loops with optional cloud compute
- Update ManagedAgent factory with deprecation warnings for LLM routing overload
- Add proper error handling for compute provider misuse
- Maintain full backward compatibility with all existing imports
- Update examples to demonstrate new clear semantics
- Add comprehensive tests for new backend semantics

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: MervinPraison <[email protected]>

* examples: update managed-agents provider examples to use new HostedAgent/LocalAgent classes

- Create new canonical examples demonstrating HostedAgent vs LocalAgent usage
- Update existing examples to use clear semantic distinctions
- Add runtime_hosted_anthropic.py for true managed runtime usage
- Add runtime_local_*.py examples for local execution with different LLMs
- Update all_providers.py to use LocalAgent with compute backends
- Update local_basic.py to use LocalAgent semantics
- Add comprehensive test suite for backend semantics

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: MervinPraison <[email protected]>

* fix: resolve P1 backward compatibility and routing issues

- Fix ManagedAgent compute provider routing: maintain backward compatibility
  for e2b/modal/etc by routing to LocalManagedAgent with deprecation warning
  instead of ValueError (fixes hard breaking change)
- Fix LocalAgent provider preservation: preserve provider value for LLM routing
  to maintain _resolve_model() prefix behavior (ollama/, gemini/)
- Fix spurious deprecation warnings: auto-detected provider=local no longer
  triggers warnings for users who never passed provider=
- Remove unused os import from hosted_agent.py
- Improve error messages with provider-specific guidance
- Fix test fragility with exact warning counts and identity checks

Addresses all P1 issues identified by Greptile and CodeRabbit reviewers.

Co-authored-by: Mervin Praison <[email protected]>

---------

Co-authored-by: praisonai-triage-agent[bot] <272766704+praisonai-triage-agent[bot]@users.noreply.github.com>
Co-authored-by: MervinPraison <[email protected]>
2026-04-25 07:05:06 +01:00

47 lines
1.4 KiB
Python

"""Local agent — basic local execution with gpt-4o-mini.
No external infrastructure needed. Runs the agent loop locally.
Uses the new canonical LocalAgent class for clarity.
"""
from praisonai import Agent
from praisonai.integrations import LocalAgent, LocalAgentConfig
# Create a local agent (runs locally, no managed runtime)
managed = LocalAgent(
config=LocalAgentConfig(
model="gpt-4o-mini",
system="You are a helpful assistant. Be concise.",
name="LocalAgent",
),
)
agent = Agent(name="local-basic", backend=managed)
# 1. Basic execution
print("[1] Basic execution...")
result = agent.start("What is the capital of France? One word.", stream=True)
print(f" Result: {result}")
# 2. Agent metadata
print(f"\n[2] Agent ID: {managed.agent_id}")
print(f" Version: {managed.agent_version}")
print(f" Env ID: {managed.environment_id}")
print(f" Session: {managed.session_id}")
# 3. Multi-turn (same session keeps context)
print("\n[3] Multi-turn...")
result = agent.start("What country is that city in?", stream=True)
print(f" Result: {result}")
# 4. Usage tracking
info = managed.retrieve_session()
print(f"\n[4] Usage: in={info['usage']['input_tokens']}, out={info['usage']['output_tokens']}")
# 5. List sessions
sessions = managed.list_sessions()
print(f"\n[5] Sessions: {len(sessions)}")
for s in sessions:
print(f" {s['id']} | {s['status']}")
print("\nDone!")