Bedrock AgentCore Memory: list_events returns blob as string instead of document (JSON) when saved via create_event
Describe the bug
When I save a JSON object in payload[0].blob with create_event(), list_events(..., includePayloads=True) returns that blob as a string (e.g., "{content=hi, role=user}").
Docs say blob is a document (JSON value) in request and response:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-agentcore/client/create_event.html https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-agentcore/client/list_events.html
Notes: I know Amazon Bedrock AgentCore is in preview release.
Regression Issue
- [ ] Select this option if this issue appears to be a regression.
Expected Behavior
Return a document (JSON value) for blob (object -> dict, array -> list, number -> number, etc.).
Current Behavior
Always return string, not a JSON document. Especially for dict, returns some like Java-style {k=v, ...} strings.
Reproduction Steps
import boto3
from datetime import datetime, timezone
REGION = "us-east-1"
MEMORY_ID = "<PUT-YOUR-MEMORY-ID>" # created beforehand
client = boto3.client("bedrock-agentcore", region_name=REGION)
# Save a JSON object into blob (document)
client.create_event(
memoryId=MEMORY_ID,
actorId="user_123",
sessionId="session_123",
eventTimestamp=datetime.now(timezone.utc),
payload=[{"blob": {"role": "user", "content": "hi"}}],
)
# Read it back
out = client.list_events(
memoryId=MEMORY_ID,
actorId="user_123",
sessionId="session_123",
includePayloads=True,
maxResults=1,
)
blob = out["events"][0]["payload"][0]["blob"]
print(type(blob), blob)
output:
<class 'str'> {content=hi, role=user}
Possible Solution
current workaround:
serialize as JSON strings before create and de-serialize after retrieve, by myself.
import json
client.create_event(
memoryId=MEMORY_ID,
actorId="user_123",
sessionId="session_123",
eventTimestamp=datetime.now(timezone.utc),
payload=[{"blob": json.dumps({"role": "user", "content": "hi"})}], # serialize
)
out = client.list_events(
memoryId=MEMORY_ID,
actorId="user_123",
sessionId="session_123",
includePayloads=True,
maxResults=1,
)
blob = json.loads(out["events"][0]["payload"][0]["blob"]) # de-serialize
print(type(blob), blob)
output:
<class 'dict'> {'role': 'user', 'content': 'hi'}
Additional Information/Context
AWS-CLI(aws-cli/2.29.1 Python/3.13.7 Darwin/23.6.0 source/arm64) seems the same behavior, so this comes from upstream API behavior?
REGION="us-east-1"
MEMORY_ID=$(
aws bedrock-agentcore-control create-memory \
--region $REGION \
--name blob_cli_test \
--event-expiry-duration 30 \
--query 'memory.id' --output text
)
aws bedrock-agentcore create-event \
--region $REGION \
--memory-id "$MEMORY_ID" \
--actor-id "user_123" \
--session-id "session_123" \
--event-timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--payload '[{"blob":{"role":"user","content":"hello"}}]'
aws bedrock-agentcore list-events \
--region $REGION \
--memory-id "$MEMORY_ID" \
--actor-id "user_123" \
--session-id "session_123" \
--include-payloads \
--max-results 1 \
--output json \
| jq '.events[0].payload[0].blob | (type), .'
"string"
"{content=hello, role=user}"
SDK version used
1.40.25
Environment details (OS name and version, etc.)
ubuntu: 24.04, Python: 3.12.11
Hi @kun432, thanks for reaching out. I have repro'd the issue and and response is coming from the Bedrock itself. It gives:
"payload":[{"blob":"{content=hi, role=user}"}].
I have reached out to the Service Team in regards and it does not conform their documentation. An update will be given once the team has updates.
Internal Ref: P303288467
Any updates on this issue ? Getting the same issue.
might be a little off topic though, blob payload has a restriction.
https://aws.amazon.com/jp/blogs/machine-learning/amazon-bedrock-agentcore-memory-building-context-aware-agents/
These events can be either “Conversational” (USER/ASSISTANT/TOOL or other message types) or “blob” (contains binary content that can be used to store checkpoints or agent state). Out of the two event types, only the Conversational events are used for long-term memory extraction.