Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
import boto3 import json import uuid REGION = "us-west-2" AGENT_RUNTIME_ARN = "arn:aws:bedrock-agentcore:...:agent-runtime/..." # <- your runtime ARN client = boto3.client("bedrock-agentcore", region_name=REGION) session_id = str(uuid.uuid4()) # reuse this for the SAME chat thread prompt = "Hello! Summarize what you can do in one sentence." payload = json.dumps({"prompt": prompt}).encode("utf-8") resp = client.invoke_agent_runtime( agentRuntimeArn=AGENT_RUNTIME_ARN, runtimeSessionId=session_id, contentType="application/json", accept="text/event-stream", # streaming payload=payload, ) print("runtimeSessionId:", resp.get("runtimeSessionId")) print("statusCode:", resp.get("statusCode")) # AgentCore returns a streaming body; docs show parsing SSE lines via iter_lines # (Look for lines starting with "data: ") for line in resp["response"].iter_lines(chunk_size=10): if not line: continue text = line.decode("utf-8", errors="replace") if text.startswith("data: "): print(text[6:]) # JSON or text chunks depending on your agent
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)