Skip to content

Proposal: lifecycle-managed Extension Runtime for safe agent self-extension #2973

Description

@xxhZs

Problem

Maka currently has several extension mechanisms, including built-in tools, deferred load_tools groups, Skills, MCP, automations, and Agent Graph capabilities. However, these capabilities are assembled through fixed startup or backend wiring. An agent can reveal a tool that was already registered, but it cannot safely define, activate, inspect, update, stop, or remove a new runtime capability.

Adding dynamic scripts directly to the existing process would create a second problem: a script update could mutate the tool surface or leave listeners, timers, UI entries, and other effects behind while an Agent Run is active. This would conflict with Maka's durable Run, continuation, permission, and recovery guarantees.

The goal should not be a second plugin runtime beside the existing one. Maka's shipped capabilities should remain the protected core composition, while installed and agent-authored extensions enter through the same composition boundary.

Desired outcome

Introduce a lifecycle-managed Extension Runtime that lets capabilities behave like applications:

  • Define or install an immutable extension revision without running it.
  • Activate an exact revision and own every effect it contributes.
  • Stop it cleanly while retaining the revision.
  • Update through a prepared candidate without disturbing the current activation.
  • Roll back when preparation or activation fails.
  • Uninstall only after active work has drained.
  • Inspect the live extension surface and its diagnostics.

Static packages and agent-authored scripts should use one model. Temporary versus persistent behavior should be expressed by binding scope and lifetime rather than separate plugin systems.

Each Agent Run should use an immutable Extension Composition snapshot. Changes produce a candidate composition for future work and must never mutate the composition of an active Run.

The protected core should initially remain non-replaceable. Extensions may contribute through explicit, typed surfaces, introduced progressively:

  1. Tools
  2. Runtime inspection and control
  3. Agent-authored session extensions
  4. UI slots
  5. Read-only runtime observation
  6. Restricted decision hooks, context, state, timers, and Agent Graph capabilities

Untrusted or agent-authored code must not execute directly inside the Electron main process. Lifecycle cleanup and execution isolation are separate requirements: lifecycle ownership prevents leaked effects, while an isolated extension host prevents faulty code from destabilizing the core process.

Proposed product and architecture direction

Core concepts

  • Extension: stable identity.
  • Revision: immutable package contents, manifest, permissions, and compatibility metadata.
  • Contribution: one capability exposed through a typed extension surface, such as a Tool or UI slot.
  • Binding: declares which revision is desired for a process, user, workspace, session, or run scope.
  • Composition Snapshot: deterministic resolved set of core and extension contributions used by a Run.
  • Activation: one live instance that owns its workers, registrations, listeners, timers, UI entries, and state handles.

Lifecycle semantics

Keep definition and execution separate:

define/install
  -> validate
  -> prepare exact revision
  -> activate
  -> drain
  -> stop
  -> uninstall

Updates should follow current/candidate semantics:

current activation remains live
  -> prepare candidate
  -> validate dependencies and policy
  -> health check
  -> commit at a safe Runtime boundary
  -> drain old activation

A failed candidate must not move the committed pointer.

Integration principle

The existing built-in tool set becomes the protected core provider of the same composition model. Existing model, collaboration-mode, permission, sandbox, and product-tool filters remain the final authority after extension contributions are resolved.

The existing Runtime generation and safe admission boundaries should remain authoritative. Extension changes may become visible to a later provider step or later Turn only when the corresponding immutable snapshot has been admitted safely.

Agent experience

After the runtime model is proven with trusted extensions, expose a small control surface:

inspect -> define -> validate/test -> run -> inspect -> stop/update -> remove

Defining a revision must have no runtime effect. Agent-authored revisions should initially be session-scoped, explicitly approved, resource-limited, and executed outside the core process.

Suggested roadmap

Phase 0 — Boundary and invariants

  • Define protected core authority versus extensible capability surfaces.
  • Specify Run composition immutability, cleanup, rollback, permission, and recovery invariants.

Phase 1 — Lifecycle and revision model

  • Establish Extension, Revision, Contribution, Binding, Composition Snapshot, and Activation semantics.
  • Prove complete cleanup, dependency waiting, failed-start rollback, and current/candidate behavior independently of product features.

Phase 2 — Trusted Tool vertical slice

  • Use Tool as the first contribution type.
  • Route trusted static Tool extensions through the same final filters as built-in tools.
  • Preserve exact behavior when only the core composition is enabled.
  • Pin each Run to an immutable composition.

Phase 3 — Runtime inspection and control

  • Expose the actual live contribution catalog, composition, owners, dependencies, activation status, and diagnostics.
  • Use one control plane for the UI and agent-facing operations.

Phase 4 — Agent-authored session extensions

  • Support define, validate/test, run, call, stop, update, rollback, and remove.
  • Keep definitions effect-free until activation.
  • Use isolated execution and explicit capabilities.
  • Allow immediate calls through a stable extension bridge; advertise a new native tool schema only at a safe request boundary.

Phase 5 — UI contributions

  • Add explicit UI slots and coordinated host/client activation.
  • Retract both sides as one owned activation.
  • Start with declarative or otherwise isolated UI contributions.

Phase 6 — Additional contribution surfaces

  • Add read-only observation first.
  • Then introduce restricted decision hooks, context contributions, state, timers, and existing Agent Graph or child-agent capabilities.
  • Keep core Runtime authority and durable event semantics non-overridable.

Phase 7 — Persistence and distribution

  • Add persistent bindings, restart recovery, promotion from session draft to verified release, signatures, compatibility metadata, revocation, and catalog workflows.

Non-goals for the first milestone

  • Replacing Maka's core Runtime, persistence, continuation, permission, or credential authorities.
  • Making every Domain Module dynamically replaceable.
  • Allowing arbitrary scripts inside Electron main or the main renderer.
  • Shipping Tool, UI, and unrestricted hooks simultaneously.
  • Building a marketplace before the lifecycle, Tool slice, composition, and inspection model are proven.

Acceptance principles

  • An active Run never changes composition.
  • Revisions are immutable.
  • Every activation-owned effect is removed on stop, failure, update, and scope disposal.
  • A failed candidate cannot affect the committed activation.
  • Extension permissions cannot exceed final Runtime policy.
  • Recovery never silently substitutes another revision.
  • Disabling all extension bindings yields the same core-only behavior through the same composition path.

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