Skip to content

feat: per-agent session_mode for automated invocations #2342

Description

@neo-wanderer

Problem

Agents invoked by automated sources (cron ticks, event triggers, agent_send) always reuse the agent's persistent session. Context accumulates indefinitely across background invocations — fine for stateful assistants, but wrong for stateless jobs like "summarize today's emails" or "run a health check" where each invocation should start clean.

There is currently no way for an agent author to opt into fresh sessions per automated invocation without writing custom session management logic.

Proposed solution

Add a session_mode field to AgentManifest (set in agent.toml) with two values:

  • persistent (default) — reuse the agent's persistent session, preserving backward compatibility.
  • new — create a fresh session for each automated invocation (cron tick, trigger fire, agent_send call).

Additionally, support per-trigger overrides via Trigger.session_mode, so a single agent can have most triggers reuse the persistent session while specific triggers (e.g. a daily digest) start fresh.

Example

# agent.toml
session_mode = "new"   # every cron/trigger invocation starts clean

Constraints

  • Channel-derived sessions (Telegram, Discord, etc.) should remain deterministic per-channel regardless of session_mode — this only affects non-channel automated invocations.
  • Hands share AgentManifest, so they get session_mode support automatically.
  • Default must be "persistent" for full backward compatibility.

Implementation

PR: #2341

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions