feat(events): widen content type to str|dict in all store backends

Allow event content to be a dict (for structured OpenAI-format messages)
in addition to plain strings. Dict values are JSON-serialized for the DB
backend and deserialized on read; memory and JSONL backends handle dicts
natively. Trace truncation now serializes dicts to JSON before measuring.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
rayhpeng
2026-04-04 08:49:25 +08:00
parent b92ddafd4b
commit 17eb509dbd
5 changed files with 106 additions and 9 deletions
@@ -243,7 +243,7 @@ class RunJournal(BaseCallbackHandler):
# -- Internal methods --
def _put(self, *, event_type: str, category: str, content: str = "", metadata: dict | None = None) -> None:
def _put(self, *, event_type: str, category: str, content: str | dict = "", metadata: dict | None = None) -> None:
self._buffer.append({
"thread_id": self.thread_id,
"run_id": self.run_id,