aws / aws/bedrock-agentcore-sdk-python
[Bug] update_message fails with parameter validation error when SessionMessage.message_id is a Strands positional integer index
- Vorherrschende Sprache
- Python
- Sterne
- 761
- Forks
- 147
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 7
Beschreibung
**Describe the bug**
When redact_latest_message is triggered (e.g. via guardrail redaction), update_message attempts to delete the old AWS event using session_message.message_id as the eventId.
However, Strands' SessionMessage.message_id is a sequential integer index (e.g. 4), not an AWS eventId string (e.g. "4#abc123f"). The AWS delete_event API requires eventId to be a string matching [0-9]+#[a-fA-F0-9]+, so [botocore rejects](https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_DeleteEvent.html#API_DeleteEvent_RequestSyntax) the integer at parameter validation, causing the redaction to fail with
**Error**
```
Failed to update message: could not delete old event: Parameter validation failed: Invalid type for parameter eventId, value: 4, type: , valid types:
```
**To Reproduce**
- Strands' RepositorySessionManager.initialize_agent calls session_repository.create_message() directly with SessionMessage objects whose message_id is a sequential integer index (0, 1, 2...). It then sets _latest_agent_message[agent_id] to the last such SessionMessage.
- When redact_latest_message is subsequently called, it reads _latest_agent_message[agent_id] and passes it to update_message.
- update_message extracts old_message_id = session_message.message_id -> this is the integer 4, not an AWS eventId string.
- It then calls gmdp_client.delete_event(eventId=old_message_id), but the AWS API requires eventId to match pattern [0-9]+#[a-fA-F0-9]+ (e.g. "4#abc123f"), so botocore rejects the integer with a ParamValidationError.
**Expected behavior**
_latest_agent_message[agent_id].message_id should always contain the AWS eventId string returned by create_event, not the Strands positional integer index.
**Where**
src/bedrock_agentcore/memory/integrations/strands/session_manager.py, update_message -> delete_event call.
Beitragsleitfaden
Rechercherichtung
Beginne in src/bedrock_agentcore/memory/integrations/strands/session_manager.py und konzentriere dich auf update_message sowie den create_message/create_event-Pfad, der _latest_agent_message setzt. Verfolge, welcher Bezeichner in SessionMessage.message_id gespeichert wird, und überprüfe anschließend, dass das Redigieren der neuesten Nachricht das Ereignis ohne einen Parametervalidierungsfehler löscht und die AWS-Ereignis-ID beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, python
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Ruhig
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 68/100