Skip to content

feat(storage): add content_filters to DynamoDbChatStorage#537

Open
nuthalapativarun wants to merge 1 commit into
2FastLabs:mainfrom
nuthalapativarun:fix/131-dynamodb-content-filters
Open

feat(storage): add content_filters to DynamoDbChatStorage#537
nuthalapativarun wants to merge 1 commit into
2FastLabs:mainfrom
nuthalapativarun:fix/131-dynamodb-content-filters

Conversation

@nuthalapativarun

Copy link
Copy Markdown

Issue Link (REQUIRED)

Fixes #131

Summary

Changes

Adds an optional content_filters parameter to DynamoDbChatStorage — a list of (original, placeholder) string pairs. When provided:

  • On save (save_chat_message, save_chat_messages): each original value is replaced by its placeholder before the message is written to DynamoDB.
  • On fetch (fetch_chat, fetch_chat_with_timestamp, fetch_all_chats): placeholders are restored to their original values before returning to the caller.

This eliminates the need for a custom storage implementation when sensitive content (e.g. company names, tokens) must not be persisted in plain text.

User experience

Before: users had to subclass DynamoDbChatStorage or write a custom storage class to mask sensitive values.

After:

storage = DynamoDbChatStorage(
    table_name="my-table",
    region="us-east-1",
    content_filters=[
        ("acme-corp", "#COMPANY#"),
        ("secret-token-xyz", "#TOKEN#"),
    ]
)

DynamoDB stores #COMPANY#; the agent always sees acme-corp.

Checklist

  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented
  • I have linked this PR to an existing issue (required)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Adds an optional content_filters parameter — a list of (original, placeholder)
pairs — to DynamoDbChatStorage. Sensitive values are replaced with their
placeholders before writing to DynamoDB and restored on every read path
(fetch_chat, fetch_chat_with_timestamp, fetch_all_chats).

Closes 2FastLabs#131
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: DynamoDbChatStorage option to replace sensitive content by placeholder

1 participant