Skip to content

feat(plugin): support plugin-managed background tasks - #67928

Open
chenpao7 wants to merge 2 commits into
anomalyco:devfrom
chenpao7:plugin-background-tasks
Open

chenpao7 wants to merge 2 commits into
anomalyco:devfrom
chenpao7:plugin-background-tasks

Conversation

@chenpao7

@chenpao7 chenpao7 commented Dec 3, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #60860

Type of change

  • New feature

What does this PR do?

Plugins can run work outside a Session, such as remote benchmarks, but the host had no way to know the Session was still waiting. /goal could treat the idle Session as stalled, continue unnecessarily, and eventually pause with "Not making progress".

Add a host-managed plugin background task registry and expose ctx.background.register({ sessionID, description }). Active tasks are included in SessionIdle.background as { kind: "plugin", ... }. /goal treats its own active plugin task like other background work: it stops evaluating until the plugin settles the task and sends a synthetic message. Registering does not wake the Session, so task lifecycle and wake-up stay separate; WAIT_LIMIT still pauses a goal when no wake-up arrives.

Tasks are scoped to the plugin activation and removed when it unloads. Completion is idempotent, duplicate ids are rejected per plugin, and task state is process-local rather than persisted across restart.

No feature flag: this is new plugin API surface, and the behavior only applies when a plugin registers a task.

How did you verify your code works?

  • bun run typecheck:tsc in packages/core and packages/plugin
  • bun run check from the repo root: 37/37 packages typecheck
  • bun run test in packages/core: 8343 pass, 34 skip, 2 failures in existing shell tests caused by macOS bash 3.2.57; both reproduce in isolation
  • bun run test in packages/plugin: 38 pass
  • bun run test in packages/server: 238 pass, 1 skip
  • New tests cover registry lifecycle, plugin-context cleanup, Location registry wiring, and /goal wait/resume behavior
  • Prettier check passes on all changed files

Screenshots / recordings

N/A (server-side plugin API)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add ctx.background.register so plugins can declare external work for a Session. Active tasks appear in SessionIdle.background and /goal waits for them instead of continuing or reporting a stall. Tasks are scoped to the plugin activation and removed when it unloads.
@chenpao7

chenpao7 commented Dec 3, 2026

Copy link
Copy Markdown
Author

The triage-pr-standards run is a startup_failure with zero jobs, and the same failure is currently affecting several other PR branches (for example hive-swarms, graduate-mcp-resilience, clean-env-layer, and mcp-lifecycle-adt), so it looks repository-wide rather than specific to this change.

The other checks (check, check-test, check-nix, check-bot-scope) are in action_required, waiting for maintainer approval for this fork PR. Could a maintainer approve the workflow runs when convenient?

The branch has been updated with dev (bc49bf16), and the relevant tests plus packages/core / packages/plugin typechecks pass locally.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: /goal: let plugins declare background work in SessionIdle.background

1 participant