anomalyco / anomalyco/opencode

[FEATURE]: Add explicit hidden or ephemeral sessions for plugin background tasks

Open
#40,863 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 6, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Feature hasn't been suggested before.
  • I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request

Plugins sometimes need to run LLM tasks in the background without exposing those tasks as normal user conversations.

I built a local long-term memory plugin that uses this pattern:

  1. Wait for a user session to become idle.
  2. Create a child session with parentID.
  3. Send a constrained consolidation prompt.
  4. Read and persist the result.
  5. Delete the child session.

This works, but it relies on child sessions being excluded from user-facing root session lists. parentID represents hierarchy; it does not explicitly guarantee that a session is hidden, temporary, or automatically cleaned up.

A child session can still appear in unfiltered session queries and may remain orphaned if the process exits before cleanup.

I would like to propose an explicit opt-in property when creating a session, for example:

client.session.create({
  body: {
    title: "memory-consolidation",
    parentID,
    hidden: true,
    ephemeral: true,
  },
})

Possible semantics:

hidden: true excludes the session from normal user-facing session lists and pickers.
Hidden sessions remain accessible by exact ID and through an explicit includeHidden query option.
ephemeral: true allows automatic cleanup after completion, cancellation, process restart, or a configurable TTL.
parentID remains independent from visibility and lifetime.
Existing session behavior remains unchanged unless these options are enabled.

This would support background use cases such as:

memory consolidation;
indexing and context extraction;
automated summaries;
evaluation or validation passes;
plugin-managed background agents.

I have a working plugin and end-to-end tests demonstrating that child sessions can execute prompts, remain absent from root session listings, return structured results, and be deleted after completion.

Related discussions include #19999 and #20849, but this request is intentionally narrower: it concerns only session visibility and lifecycle for plugin-created background tasks.

I am happy to contribute documentation and tests first, or an implementation after the maintainers confirm the preferred API and semantics.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.