Main entry point for the browser agent. Args: payload: Request payload containing the prompt context: Runtime context (session info) Yields: Streaming events from the agent
(payload, context)
| 86 | |
| 87 | @app.entrypoint |
| 88 | async def invoke(payload, context): |
| 89 | """ |
| 90 | Main entry point for the browser agent. |
| 91 | |
| 92 | Args: |
| 93 | payload: Request payload containing the prompt |
| 94 | context: Runtime context (session info) |
| 95 | |
| 96 | Yields: |
| 97 | Streaming events from the agent |
| 98 | """ |
| 99 | prompt = payload.get("prompt", "Hello!") |
| 100 | session_id = getattr(context, 'session_id', 'default') if context else "default" |
| 101 | |
| 102 | logger.info(f"Session ID: {session_id}") |
| 103 | logger.info(f"Prompt: {prompt}") |
| 104 | logger.info(f"Model: {MODEL_ID}") |
| 105 | |
| 106 | # Create agent for this request |
| 107 | agent = create_agent() |
| 108 | |
| 109 | # Stream the response |
| 110 | async for event in agent.stream_async(prompt): |
| 111 | yield event |
| 112 | |
| 113 | |
| 114 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected