This directory contains examples demonstrating the complete lifecycle of AGB sessions.
- Use
CreateSessionParamsto configure your session (image, timeouts). - Always check
result.successbefore proceeding.
- You can reconnect to any active session using
agb.get(session_id). - This is useful for stateless applications (e.g., web servers) that need to resume control of a session.
- For high-throughput applications, creating a new session for every request is inefficient.
- Maintaining a pool of "warm" sessions allows for faster execution and better resource utilization.
- Use
session.get_metrics()to retrieve real-time resource usage information. - Metrics include CPU usage, memory usage, disk usage, and network statistics.
- Useful for monitoring session performance and resource consumption.
- Always call
agb.delete(session)in afinallyblock or when the session is no longer needed to avoid unnecessary charges.
Basic session creation, listing, and deletion.
<<< ./create_session.py
How to retrieve an existing session by ID.
<<< ./get_session.py
Implementation of a thread-safe session pool for high-concurrency applications.
<<< ./session_pool.py
Demonstrates how to retrieve real-time session metrics including CPU, memory, disk, and network usage.
<<< ./get_metrics.py
Demonstrates how to list and call MCP (Model Context Protocol) tools available in a session.
<<< ./mcp_tools.py