Summary
All cron fires for an agent running in Persistent mode (the default) share a single session keyed as (agent_id, "cron"). This session can grow over time.
Update: cron_session_max_tokens and cron_session_max_messages config fields DO exist (see crates/librefang-types/src/config/types.rs:2685,2692) and are applied as a pruning step before each cron fire (kernel/mod.rs:12094-12124). Both default to None (disabled).
Remaining Gaps
-
No warning when approaching provider context window: There is no tracing::warn! when the cron session grows close to the model's context limit. The first indication of growth is a hard provider error.
-
No API observability: session_token_count is not exposed in the cron job status/history API, so operators cannot observe session growth trends.
-
Documentation gap: cron_session_max_tokens / cron_session_max_messages are undocumented in the dashboard and not surfaced in any config UI. Operators who need per-fire isolation typically have to discover these fields by reading the source.
-
Pruning happens before-fire, not gradually: Pruning drops old messages when the limit is hit, which causes context discontinuity. A warn-and-compact approach (similar to how session compaction works in LLM agent loops) would be more graceful.
Proposed Improvements
- Emit
tracing::warn! when a cron session exceeds a configurable fraction of the provider's context window before triggering the LLM call
- Expose
session_message_count and estimated session_token_count in the cron job status response
- Document
cron_session_max_tokens/cron_session_max_messages prominently in the cron configuration UI and docs
- Add a gentle
summarize-and-trim compaction mode rather than hard truncation
Summary
All cron fires for an agent running in
Persistentmode (the default) share a single session keyed as(agent_id, "cron"). This session can grow over time.Update:
cron_session_max_tokensandcron_session_max_messagesconfig fields DO exist (seecrates/librefang-types/src/config/types.rs:2685,2692) and are applied as a pruning step before each cron fire (kernel/mod.rs:12094-12124). Both default toNone(disabled).Remaining Gaps
No warning when approaching provider context window: There is no
tracing::warn!when the cron session grows close to the model's context limit. The first indication of growth is a hard provider error.No API observability:
session_token_countis not exposed in the cron job status/history API, so operators cannot observe session growth trends.Documentation gap:
cron_session_max_tokens/cron_session_max_messagesare undocumented in the dashboard and not surfaced in any config UI. Operators who need per-fire isolation typically have to discover these fields by reading the source.Pruning happens before-fire, not gradually: Pruning drops old messages when the limit is hit, which causes context discontinuity. A warn-and-compact approach (similar to how session compaction works in LLM agent loops) would be more graceful.
Proposed Improvements
tracing::warn!when a cron session exceeds a configurable fraction of the provider's context window before triggering the LLM callsession_message_countand estimatedsession_token_countin the cron job status responsecron_session_max_tokens/cron_session_max_messagesprominently in the cron configuration UI and docssummarize-and-trimcompaction mode rather than hard truncation