feat(plugins): add public subagent lifecycle API

This commit is contained in:
Tony Simons 2026-07-12 13:49:45 -05:00 committed by Teknium
parent 0a2c245cd6
commit 1865fb5fcd
4 changed files with 650 additions and 0 deletions

View file

@ -344,6 +344,7 @@ class PluginContext:
self._manager = manager
# Lazy-built host-owned LLM facade — see ctx.llm property below.
self._llm: Any = None
self._subagent_lifecycle: Any = None
# -- host-owned LLM access ----------------------------------------------
@ -364,6 +365,22 @@ class PluginContext:
self._llm = PluginLlm(plugin_id=plugin_id)
return self._llm
@property
def subagent_lifecycle(self) -> Any:
"""Return the public, plugin-safe subagent lifecycle service.
The service only resolves the active host-owned parent agent when a
child is launched. Plugins receive serializable handles and immutable
snapshots; they never receive a live agent or a private registry.
"""
if self._subagent_lifecycle is None:
from agent.subagent_lifecycle import SubagentLifecycleService
self._subagent_lifecycle = SubagentLifecycleService(
lambda: getattr(self._manager._cli_ref, "agent", None)
if self._manager._cli_ref is not None else None
)
return self._subagent_lifecycle
# -- profile awareness --------------------------------------------------
@property