Skip to content

Bedrock AgentCore Memory: list_events returns blob as string instead of document (JSON) when saved via create_event #4614

@kun432

Description

@kun432

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

Metadata

Metadata

Assignees

Labels

bedrockp3This is a minor priority issueservice-apiThis issue is caused by the service API, not the SDK implementation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions