๊ฐ€์ž… ํ›„ ์ดˆ๋Œ€ ๋งํฌ๋ฅผ ๊ณต์œ ํ•˜๋ฉด ๋™์˜์ƒ ์žฌ์ƒ ๋ฐ ์ดˆ๋Œ€ ๋ณด์ƒ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
๊ฐ€์ž… May 2026
286 ํŒ”๋กœ์ž‰ ์ค‘    469 ํŒฌ
# Useful but Little-Known Features of OpenAI Agent SDK ๐ŸŒ Does your agent's conversation history contain sensitive data stored in plaintext? EncryptedSession protects conversation data with Fernet encryption and supports TTL-based auto-expiration. ๐Ÿ“Œ Title: Encrypted Session (EncryptedSession) ๐Ÿ”— URL: ๐Ÿงฉ Overview `EncryptedSession` is a drop-in wrapper that encrypts conversation data for any session backend passed as `underlying_session`. It uses Fernet encryption with HKDF per-session key derivation (info string `"agents.session-store.hkdf.v1"`, session ID as salt), ensuring cryptographic isolation between sessions. Items older than `ttl` (default 600 seconds) are silently skipped on retrieval. Provide a high-entropy master key such as `Fernet.generate_key()` output โ€” raw strings are still accepted for compatibility, but passwords and other low-entropy secrets are unsuitable. ๐Ÿ›  How to use it ```python import os from cryptography.fernet import Fernet from agents import SQLiteSession from agents.extensions.memory import EncryptedSession # Wrap a base session with encryption base_session = SQLiteSession("chat-001", "sessions.db") # Use a high-entropy master key, e.g. generated with Fernet encryption_key = Fernet.generate_key().decode("ascii") encrypted = EncryptedSession( session_id="chat-001", underlying_session=base_session, encryption_key=encryption_key, ttl=3600, # Expire after 1 hour (default is 600 seconds) ) # For persistent storage, load and reuse the same stored key encrypted = EncryptedSession( session_id="chat-001", underlying_session=base_session, encryption_key=os.environ["SESSION_ENCRYPTION_KEY"], ttl=7200, ) # Use the same interface as any other session items = await encrypted.get_items() ``` ๐Ÿ— Building it into production ใƒปMeet compliance requirements in regulated industries like healthcare and finance ใƒปHKDF derives unique keys per session, so one session's compromise doesn't affect others ใƒปUse TTL for "cryptographic data erasure" โ€” data becomes unrecoverable after expiration ใƒปWraps existing SQLiteSession / RedisSession with zero migration cost ๐Ÿ’ก Use cases ๐Ÿฅ Encrypted storage for conversations containing medical information ๐Ÿฆ Security hardening for agents handling financial data ๐Ÿ” GDPR "right to be forgotten" compliance via TTL expiration ๐Ÿ›ก Inter-session data isolation in multi-tenant environments โš ๏ธ Watch out Install the `encrypt` extra first: `pip install 'openai-agents[encrypt]'`. Content search methods like `find_turns_by_content()` don't work on encrypted data. If search is needed, maintain a separate search index. Also, losing the encryption key makes data permanently unrecoverable โ€” secure key management (e.g., Secret Manager) is essential. Changing `encryption_key` does not re-encrypt stored records, so existing data still requires the original key. โœจ With EncryptedSession, protect conversation data with just one line of code. #OpenAIAgentSDK# #AIAgent#
๋” ๋ณด๊ธฐ