MCPcopy
hub / github.com/phuryn/claude-usage / is_subagent_record

Function is_subagent_record

scanner.py:235–250  ·  view source on GitHub ↗

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="")

Source from the content-addressed store, hash-verified

233
234
235def 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
253def record_agent_id(record):

Callers 2

parse_jsonl_fileFunction · 0.85
scanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected