Skip to content

[Feature Request] Post-subagent completion extension hook #22358

@anshumanbh

Description

@anshumanbh

Summary

Add an extension hook (e.g. post_subagent_complete) that fires after a spawned subagent finishes and before the completion announcement is sent to the parent session.

Use Case

Automatically generate structured trajectory files (task → decisions → retrospective) after significant subagent work completes. Currently only possible as a behavioral LLM rule — non-deterministic.

A programmatic hook would allow:

  • Inspecting the subagent session history and completion output
  • Running arbitrary logic (summarize into trajectory, update search index)
  • Modifying/enriching the completion announcement
  • Filtering noisy completions

Proposed API

openclaw.on("subagent_complete", async (event, ctx) => {
  // event.sessionKey, event.label, event.agentId
  // event.result, event.duration, event.usage
  await saveTrajectory(event);
  return { announcement: enrichedSummary };
});

Context

Similar to PI framework agent_end event handler. The completion announcement already flows through the gateway — this hook would expose it as an extension point. Useful for building memory/learning systems on top of OpenClaw.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions