mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
- Add hanzo-kms v1.0.0: Secret management SDK compatible with Infisical API - Sync and async clients with multiple auth methods (Universal, AWS IAM, Azure, GCP, K8s) - Full CRUD operations for secrets with environment injection - Add MCP proxy system for lazy-loading external MCP servers - mcp_proxy.py: Dynamic MCP server connection and tool discovery - proxy_tool.py: Tool for managing external MCP server proxies - platform_auth.py: Hanzo Platform authentication utilities - Built-in servers: platform, github, cloudflare, postgres, sqlite, docker, k8s - Add agent reflexion module for self-correction and rule management - ReflexionEngine for reflection and rule-based behavior updates - Integration with hanzo-memory for persistent rules - Add self_learning_agent example demonstrating reflexion capabilities - Update ps_tool with improved process management and log handling - Update browser tools with enhanced CDP bridge and automation - Bump dependency versions across all tool packages All tests pass (3156 passed)
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
|
|
from agents import Agent, ReflexionEngine, Runner
|
|
from hanzo_memory.client import SQLiteMemoryClient
|
|
from agents.reflexion import Rule
|
|
|
|
async def main():
|
|
# 1. Initialize Memory Client (SQLite)
|
|
# Ensure the DB exists or is created
|
|
db_client = SQLiteMemoryClient(user_id="test_user")
|
|
|
|
# 2. Initialize Reflexion Engine
|
|
reflexion = ReflexionEngine(memory_client=db_client)
|
|
|
|
# 3. Add some initial rules (simulating past learning)
|
|
await reflexion.add_rule("Always double check file paths before writing.", context="coding")
|
|
|
|
# 4. Create an Agent with Reflexion
|
|
agent = Agent(
|
|
name="SelfLearningBot",
|
|
instructions="You are a helpful assistant that learns from mistakes.",
|
|
reflexion=reflexion
|
|
)
|
|
|
|
# 5. Simulate a run (in a real scenario, the runner would use these)
|
|
print(f"Agent {agent.name} initialized.")
|
|
rules = await agent.reflexion.load_rules(context="coding")
|
|
print(f"Loaded {len(rules)} rules for context 'coding':")
|
|
for r in rules:
|
|
print(f" - {r.content}")
|
|
|
|
# 6. Simulate a learning event
|
|
print("\nSimulating reflection...")
|
|
new_rule = await agent.reflexion.add_rule("Use pathlib for path manipulations.", context="coding")
|
|
print(f"Added new rule: {new_rule.content}")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|