mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
refactor(agents): bind subagent threads in core (#88416)
Move subagent thread binding ownership into core so session-mode spawns prepare channel bindings before launching the child agent. Deprecate the legacy subagent_spawning SDK hook in code, compatibility metadata, diagnostics, and plugin docs; plugin authors should observe subagent_spawned instead. Verification: - node scripts/run-vitest.mjs src/agents/sessions-spawn-hooks.test.ts src/agents/subagent-spawn.thread-binding.test.ts src/agents/subagent-spawn.workspace.test.ts src/agents/subagent-spawn.mode-session-diagnostics.test.ts - node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo - git diff --check - .agents/skills/autoreview/scripts/autoreview --mode local - CI run 26693808952 green, including checks-node-agentic-agents-core and checks-node-agentic-plugin-sdk
This commit is contained in:
committed by
GitHub
parent
4ac90a5b48
commit
3fc0df953c
@@ -141,7 +141,9 @@ observation-only.
|
||||
|
||||
**Subagents**
|
||||
|
||||
- `subagent_spawning` / `subagent_delivery_target` / `subagent_spawned` / `subagent_ended` - coordinate subagent routing and completion delivery
|
||||
- `subagent_spawned` / `subagent_ended` - observe subagent launch and completion.
|
||||
- `subagent_delivery_target` - compatibility hook for completion delivery when no core session binding can project a route.
|
||||
- `subagent_spawning` - deprecated compatibility hook. Core now prepares `thread: true` subagent bindings through channel session-binding adapters before `subagent_spawned` fires.
|
||||
- `subagent_spawned` includes `resolvedModel` and `resolvedProvider` when OpenClaw has resolved the child session's native model before launch.
|
||||
|
||||
**Lifecycle**
|
||||
@@ -464,6 +466,10 @@ before the next major release:
|
||||
- **`before_agent_start`** remains for compatibility. New plugins should use
|
||||
`before_model_resolve` and `before_prompt_build` instead of the combined
|
||||
phase.
|
||||
- **`subagent_spawning`** remains for compatibility with older plugins, but
|
||||
new plugins should not return thread routing from it. Core prepares
|
||||
`thread: true` subagent bindings through channel session-binding adapters
|
||||
before `subagent_spawned` fires.
|
||||
- **`deactivate`** remains as a deprecated cleanup compatibility alias until
|
||||
after 2026-08-16. New plugins should use `gateway_stop`.
|
||||
- **`onResolution` in `before_tool_call`** now uses the typed
|
||||
|
||||
@@ -792,6 +792,35 @@ canonical replacement.
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="subagent_spawning hook → core thread binding">
|
||||
**Old**: `api.on("subagent_spawning", handler)` returning
|
||||
`threadBindingReady` or `deliveryOrigin`.
|
||||
|
||||
**New**: let core prepare `thread: true` subagent bindings through the
|
||||
channel session-binding adapter. Use `api.on("subagent_spawned", handler)`
|
||||
only for post-launch observation.
|
||||
|
||||
```typescript
|
||||
// Before
|
||||
api.on("subagent_spawning", async () => ({
|
||||
status: "ok",
|
||||
threadBindingReady: true,
|
||||
deliveryOrigin: { channel: "discord", to: "channel:123", threadId: "456" },
|
||||
}));
|
||||
|
||||
// After
|
||||
api.on("subagent_spawned", async (event) => {
|
||||
await observeSubagentLaunch(event);
|
||||
});
|
||||
```
|
||||
|
||||
`subagent_spawning`, `PluginHookSubagentSpawningEvent`,
|
||||
`PluginHookSubagentSpawningResult`, and
|
||||
`SubagentLifecycleHookRunner.runSubagentSpawning(...)` remain only as
|
||||
deprecated compatibility surfaces while external plugins migrate.
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Provider discovery types → provider catalog types">
|
||||
Four discovery type aliases are now thin wrappers over the
|
||||
catalog-era types:
|
||||
|
||||
Reference in New Issue
Block a user