Skip to content

Add on_child_initialized callback to PreparedBundle.spawn()#94

Open
michaeljabbour wants to merge 1 commit intomicrosoft:mainfrom
michaeljabbour:feat/on-child-initialized
Open

Add on_child_initialized callback to PreparedBundle.spawn()#94
michaeljabbour wants to merge 1 commit intomicrosoft:mainfrom
michaeljabbour:feat/on-child-initialized

Conversation

@michaeljabbour
Copy link

Summary

Adds optional on_child_initialized callback parameter to PreparedBundle.spawn() that is invoked after child session initialization but before execution begins.

This enables apps (like Kepler) to inject hooks (streaming, observability, approval) on child sessions without inlining spawn internals or creating maintenance burden as foundation evolves.

Changes

  • Add on_child_initialized: Any = None parameter to spawn() signature
  • Invoke callback after child_session.initialize() and before instruction injection
  • Callback receives initialized AmplifierSession for clean hook injection

Impact

Enables clean elimination of ~60 lines of inlined spawn logic in desktop apps that need child-session hooks. Any app requiring post-initialization, pre-execution injection gets the same benefit.

Example

prepared.spawn(
    instruction=task,
    on_child_initialized=lambda session: bridge.register_on_coordinator(
        session.coordinator, is_child=True, agent_name=agent
    )
)

Adds optional on_child_initialized callback parameter that is invoked after
child_session.initialize() completes but before child_session.execute(instruction)
begins. This enables apps to inject hooks (streaming, observability, approval)
on child sessions without inlining spawn internals.

The callback receives the initialized AmplifierSession, allowing clean injection
of child-specific configuration while maintaining API stability.
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.

1 participant