How can I determine the parent/orchestrator agent from Copilot Agent Hooks or the transcript? #199945
Replies: 5 comments 4 replies
This comment was marked as low quality.
This comment was marked as low quality.
This comment was marked as spam.
This comment was marked as spam.
-
|
Hey @Akash-2006, ran into the same wall when building agent observability. There's no native parent_agent_id exposed yet, but here's a workaround that's been working reliably for me. The trick is in when {
"hook_event_name": "PreToolUse",
"session_id": "parent-session-id", // still the parent's session
"tool_name": "runSubagent",
"tool_input": {
"agentName": "Explore" // child about to be spawned
},
"timestamp": "2026-06-23T14:46:51.162Z"
}So the flow becomes:
Works well for most cases. The one edge case to watch out for is if the same child agent name gets called multiple times quickly — in that case fall back to ordering rather than timestamp delta. Your proposed payload addition is exactly what's needed long term though: {
"parent_agent_id": "abc123",
"agent_type": "Explore"
}Would make all of this trivial to build and remove the need for any heuristics. Worth filing as a feature request if you haven't already. |
Beta Was this translation helpful? Give feedback.
-
|
This is an incredibly valid gap to call out for enterprise-grade observability. Right now, the Agent Hooks act primarily as flat event listeners—they tell you what lifecycle phase or tool execution is occurring in isolation, but they lack a structural trace context or span ID linkage to map a true DAG (Directed Acyclic Graph) of agent delegation. As you and @GARJE-01 noted, relying on sequential transcript parsing heuristics to infer lineage breaks down the moment you introduce parallel execution loops or nested agents that don't trigger a new runSubagent tool call. To pass this up as solid product feedback, exposing an explicit lineage array or a parent_agent_id tracking context within the SubagentStart and tool hook payloads is exactly how standard open telemetry tracing works. Since this is a structural limitation of the current preview SDK/CLI telemetry payload layout, opening a formal feature request or tracking this alongside the GitHub community team here is the right path forward. (If this maps out the current technical limitations of the payload schema accurately and you want to lock this down as the collective feedback view for the product team, feel free to mark this response as answered!) |
Beta Was this translation helpful? Give feedback.
-
|
I agree this looks like a real gap in the current Agent Hooks payloads. The For reliable observability, it would be much better if hooks exposed explicit lineage or trace context directly in the payload, for example: {
"agent_id": "...",
"agent_name": "...",
"parent_agent_id": "...",
"parent_agent_name": "...",
"root_session_id": "...",
"agent_path": ["Parent Agent", "Reviewer"]
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi GitHub Team,
We're using GitHub Copilot under an Organization plan and are building internal analytics around the new Agent Hooks. Our goal is to collect metrics such as:
Skills used
Parent and child agents used
Tool usage
Agent execution flow
Session-level metrics
To build these metrics, we've been using the following hooks:
PreToolUse
SubagentStart
Stop
We're also parsing the transcript available through transcript_path.
What we've found
The hook payloads provide useful information such as the session ID, transcript path, tool name, tool input, and child agent information.
For example, the Stop hook provides:
{
"timestamp": "2026-06-23T14:48:15.469Z",
"hook_event_name": "Stop",
"session_id": "402e6c4f-2c63-4093-a597-f4374ca073fa",
"transcript_path": ".../402e6c4f-2c63-4093-a597-f4374ca073fa.jsonl",
"stop_hook_active": false,
"cwd": "..."
}
The PreToolUse hook provides:
{
"timestamp": "2026-06-23T14:46:51.162Z",
"hook_event_name": "PreToolUse",
"session_id": "402e6c4f-2c63-4093-a597-f4374ca073fa",
"transcript_path": ".../402e6c4f-2c63-4093-a597-f4374ca073fa.jsonl",
"tool_name": "run_in_terminal",
"tool_input": {
"command": "...",
"goal": "...",
"mode": "sync"
},
"tool_use_id": "...",
"cwd": "..."
}
When the tool is runSubagent, we can identify the child agent from tool_input.agentName. We can also inspect the transcript and determine which child agents were invoked.
However, after inspecting:
the available Agent Hook payloads,
the generated transcript (transcript_path),
and the tool execution events,
we couldn't find any information that identifies the parent/orchestrator agent that initiated the subagent.
Example
Suppose the execution flow is:
Parent Agent
├── Explore
├── Reviewer
└── Test Agent
Using the current hooks and transcript, we can determine that Explore, Reviewer, and Test Agent were executed, but we cannot determine which parent agent delegated that work.
Question
Is there an existing hook, transcript field, or API that exposes the parent/orchestrator agent?
If this information is available somewhere else, we'd really appreciate any guidance.
If it's currently not exposed, would exposing something like the following in future hook payloads be possible?
{
"parent_agent": "runSubagent",
"parent_agent_id": "...",
"agent_type": "Explore"
}
This would make it possible to build complete parent → child agent relationships, execution graphs, and organization-level observability dashboards around Copilot Agent Hooks.
Thanks in advance for any guidance!
Beta Was this translation helpful? Give feedback.
All reactions