From 49f763a68ad2a1c65c64daef56e996e12b0142d5 Mon Sep 17 00:00:00 2001 From: saibhargavi-rapolu Date: Thu, 11 Jun 2026 10:48:52 +0530 Subject: [PATCH] Enhance trace command with configurable event count --- apps/rag-to-memory-systems-demo/app.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/apps/rag-to-memory-systems-demo/app.py b/apps/rag-to-memory-systems-demo/app.py index bea63017..13670ae3 100644 --- a/apps/rag-to-memory-systems-demo/app.py +++ b/apps/rag-to-memory-systems-demo/app.py @@ -127,7 +127,7 @@ def _styled_tag(name: str) -> Text: /preferences preferences only /facts facts only (active + provisional grouped) /episodes episodes only - /trace last 5 trace events for the current run + /trace [n] show last n trace events (default 5) /confirm flip a provisional fact to active /run new start a new run_id without exiting /reset confirm drop all tables, re-create them, re-seed (irreversible) @@ -438,7 +438,27 @@ async def handle_command( elif cmd == "/episodes": await _dump_episodes(manager, session) elif cmd == "/trace": - for e in (await manager.trace.get_run(session.run_id))[-5:]: + limit = 5 + + if arg: + try: + limit = int(arg) + + if limit <= 0: + console.print( + " [yellow]number must be greater than 0[/yellow]" + ) + return True + + except ValueError: + console.print( + " [yellow]usage:[/yellow] /trace [number]" + ) + return True + + traces = await manager.trace.get_run(session.run_id) + + for e in traces[-limit:]: console.print( f" [dim]t{e['turn_index']}[/dim] " f"[yellow]{e['event_type']}[/yellow]: "