Skip to content

Ephemeral agent flag: auto-cleanup agents on completion #194

@ptone

Description

@ptone

Summary

Add an ephemeral flag to agent creation that signals the system should automatically clean up the agent when it reaches a completed state. This would be useful for task-oriented agents that are created to perform a single job and don't need to persist afterward.

Motivation

When agents are dispatched to run a single task (e.g. via a recurring schedule or an orchestrator agent), the created agent lingers in the system after completion. Currently, cleanup requires either:

  • A parent orchestrator to subscribe to notifications and explicitly delete the child
  • Manual cleanup via scion delete
  • Waiting for the soft-delete purge cycle (if the agent was soft-deleted)

An ephemeral flag would simplify this for fire-and-forget task agents.

Proposed Approach

  • Add an ephemeral: bool field to the agent creation request and store model
  • The existing soft-delete-purge recurring handler (runs every 60 min) could be extended to auto-delete agents that are both ephemeral: true and in a terminal state (completed/error)
  • Alternatively, a dedicated lightweight reaper could run on a shorter interval

Scope

This goes beyond scheduling — it's a general agent lifecycle improvement. Useful for:

  • Scheduled task agents
  • Orchestrator-dispatched sub-agents
  • Any short-lived task agent pattern

Origin

Identified during research for the agent-scheduler-use project. The scheduler's dispatch_agent event type creates agents that linger after completion. Rather than adding orchestration logic to the scheduler, the recommended pattern is message-to-orchestrator. The ephemeral flag is a complementary convenience for cases where no orchestrator is involved.

Related

  • Soft-delete purge handler: pkg/hub/server.go (purgeHandler)
  • Agent lifecycle: pkg/store/models.go (Agent struct)
  • Notification system: pkg/hub/notifications.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions