True if a record belongs to a dispatched subagent (Task/Agent tool). Subagents are detected three ways: an explicit ``isSidechain`` flag, an ``agentId`` on the record (or its ``data`` wrapper), or a transcript path under a ``subagents`` directory (Claude Code writes one jsonl per subage
(record, source_path="")
| 233 | |
| 234 | |
| 235 | def is_subagent_record(record, source_path=""): |
| 236 | """True if a record belongs to a dispatched subagent (Task/Agent tool). |
| 237 | |
| 238 | Subagents are detected three ways: an explicit ``isSidechain`` flag, an |
| 239 | ``agentId`` on the record (or its ``data`` wrapper), or a transcript path |
| 240 | under a ``subagents`` directory (Claude Code writes one jsonl per subagent). |
| 241 | """ |
| 242 | if record.get("isSidechain"): |
| 243 | return True |
| 244 | if record.get("agentId"): |
| 245 | return True |
| 246 | data = record.get("data") |
| 247 | if isinstance(data, dict) and data.get("agentId"): |
| 248 | return True |
| 249 | sp = str(source_path).replace("\\", "/").lower() |
| 250 | return "/subagents/" in sp |
| 251 | |
| 252 | |
| 253 | def record_agent_id(record): |
no outgoing calls
no test coverage detected