SubagentContext
Defined in: agent/hooks.ts:153
Metadata present when an event originates from a subagent. Undefined for top-level agent events.
When using subagent gadgets (like BrowseWeb), hook observers receive events from both the main agent AND subagents. Check this context to distinguish.
Example
Section titled “Example”observers: { onLLMCallStart: (ctx) => { if (ctx.subagentContext) { // Event from a subagent console.log(`↳ Subagent LLM (depth=${ctx.subagentContext.depth})`); } else { // Event from the main agent console.log('Main agent LLM call'); } }}Properties
Section titled “Properties”depth:
number
Defined in: agent/hooks.ts:157
Nesting depth: 1 = direct child, 2 = grandchild, etc.
parentGadgetInvocationId
Section titled “parentGadgetInvocationId”parentGadgetInvocationId:
string
Defined in: agent/hooks.ts:155
Invocation ID of the parent gadget that spawned this subagent