MCPcopy Create free account
hub / github.com/serverless/examples / invoke

Function invoke

aws-bedrock-agentcore/python/strands-browser/agent.py:88–111  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

86
87@app.entrypoint
88async 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
114if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

create_agentFunction · 0.70

Tested by

no test coverage detected