feat: trace cron-fired agent runs alongside chat - #19
Merged
Conversation
Cron-triggered agent jobs were silently invoking record_event without a
scoped trace context, so events landed in runtime-trace.jsonl with
session_id=None and were orphaned in the viewer. Widen the trace context
from a bare session id to a typed TraceContext (kind=Chat|Cron, plus
cron job id/name) propagated via the same task-local; both the channels
boundary and the cron scheduler now scope it the same way. The viewer
gains a [CRON]-tagged session group, --kind filter, and search-by-job-name.
- runtime_trace: replace RUNTIME_TRACE_SESSION_ID with RUNTIME_TRACE_CONTEXT
carrying TraceKind + cron metadata; wrap in Arc so record_event clones a
pointer instead of 4 Strings per agent-loop call. Add is_enabled() so
callers can skip heavy payload construction when tracing is off. Legacy
JSONL parses via serde defaults (kind→Chat).
- cron::scheduler::run_agent_job: scope agent::run in TraceContext::cron
with a per-firing run_id; emit cron_job_started / cron_job_finished
bookends so the viewer has session anchors analogous to chat's
channel_message_inbound/outbound.
- trace-viewer.py: add kind/cron_job_id/cron_job_name to Turn and
ConversationSession; render cron sessions with a yellow [CRON] tag;
add --kind {chat,cron,all}; search matches cron_job_id/_name and the
cron_job_started prompt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cron-triggered agent jobs were silently invoking
record_eventwithout a scoped trace context, so events landed inruntime-trace.jsonlwithsession_id=Noneand were orphaned in the viewer (`dev/trace-viewer.py`). This change makes cron runs first-class in the trace pipeline — same detail and granularity as chat — and clearly distinguishes them in the viewer.Test plan