Threat Hunter Pre-LLM UDM Noise Filter (after_tool_callback)#
threat_hunter pairs read-only Google SecOps (Chronicle SIEM) Universal Data Model (UDM) hunting with _filter_udm_events_after_tool_callback in governed_agents/threat_hunter/triage_tools.py. Instead of passing every noisy SIEM event or alert into threat_hunter_llm (or issuing one RPC per event), the ADK after_tool_callback intercepts udm_search and list_security_alerts responses and evaluates events in multi-event batches (_BATCH_SIZE = 15, up to 60 indexed questions per gemini-decision-1 RPC), capped at _MAX_FILTER_EVENTS = 60 and _CALLBACK_BUDGET_SECONDS = 15.0 before the LLM sees the payload.
How the batched after_tool_callback threshold filter works#
_extract_event_list locates the event or alert list across direct dictionaries, structuredContent, and MCP JSON content wrappers (events, alerts, results, udmEvents, securityAlerts). _evaluate_batch then packs up to _BATCH_SIZE = 15 compactly serialized events into a single shared input string and sends indexed questions (e{i}_sev, e{i}_tp, e{i}_tactic, e{i}_next — up to 60 questions per Decision 1 RPC) to evaluate_decisions (governed_agents/threat_hunter/decision_client.py, which caches Auth Manager tokens for 300 seconds and reuses a module-level httpx.Client):
Question ID |
Decision 1 Type |
Output Mapping & Semantics |
Rubric Options / Scale |
|---|---|---|---|
|
|
0-indexed expected score ( |
|
|
|
Calibrated probability ( |
True-positive security threat vs. benign administrative activity or false positive |
|
|
Categorical |
|
|
|
Categorical |
|
Based on P(true_positive) and the callback guardrails:
P(true_positive) < 0.30(_DROP_THRESHOLD): Dropped beforethreat_hunter_llm(gemini-3.8-flash) runs and counted indropped_low_signal_count, saving downstream Flash input tokens (a modeled estimate of ~4,050tokens saved from9/18noise drops in the v3 benchmark).0.30 <= P(true_positive) < 0.85: Kept withdecision1_triagemetadata (true_positive_probability,severity,severity_score,mitre_tactic,next_action).P(true_positive) >= 0.85(_ESCALATE_THRESHOLD): Kept withdecision1_triagemetadata and tagged[HIGH_CONFIDENCE_ESCALATE](high_confidence_escalate_count).Cap and time-budget guardrails (
_MAX_FILTER_EVENTS = 60,_CALLBACK_BUDGET_SECONDS = 15.0): At most 60 events (4 batches of 15) are evaluated per tool response, and remaining batches stop if the 15.0-second deadline expires. Any unevaluated overflow events pass through cleanly inkept_itemsand are counted inpassthrough_overflow_count.
When neither GEMINI_AUTH_PROVIDER nor GEMINI_API_KEY is configured, _filter_udm_events_after_tool_callback returns None so the raw tool response passes through unchanged and hermetic unit tests pass without network access.
Figure 1. Parallel after_tool_callback UDM noise filter (_DROP_THRESHOLD = 0.30, _ESCALATE_THRESHOLD = 0.85) comparing the replayed ntdsutil.exe event on activedir.stackedpads.local (3.95 / 5.0 shifted severity, 79.96% TP, credential_access, escalate_tier2) against a benign admin discovery scan dropped before the LLM runs.#
YARA-L 2.0 vs. standard YARA and Gateway boundaries#
In both governed_agents/threat_hunter/agent.py and the tune_yaral2 rubric option, threat_hunter explicitly distinguishes Chronicle SIEM YARA-L 2.0 detection rules from standard YARA rules:
Chronicle SIEM YARA-L 2.0: Event-correlation rules written against UDM telemetry (
meta,events, andconditionsections) and inspected vialist_rules,get_rule, andlist_rule_detections.Standard YARA: File and binary payload pattern-matching rules (
stringsandconditionsections) used on artifacts rather than SIEM UDM event streams.
threat_hunter is strictly read-only on Chronicle OneMCP (udm_search, search_raw_logs, translate_udm_query, list_security_alerts, get_security_alert, fetch_alert_data, search_entity, summarize_entity, get_ioc_match, list_rules, get_rule, list_rule_detections). Mutating tools (create_rule, delete_feed, create_reference_list, execute_manual_action) and feed inspection (list_feeds) remain in ADVERTISED_DENIED_TOOLS so Agent Gateway IAM v3 CEL policies enforce live HTTP 403 denials at the boundary rather than relying on LLM self-refusal.
Live Logstory RULES_SEARCH_WORKSHOP replay#
To validate the UDM filter against realistic Windows enterprise telemetry, we replayed the Logstory RULES_SEARCH_WORKSHOP dataset into the test Google SecOps tenant:
Ingested telemetry volumes:
POWERSHELL(3,791+events),WINEVTLOG(6,975+events), andWINDOWS_SYSMON(6,350+events).Live A2A hunt (
ntdsutil.exe): Querying Chronicle OneMCP viaudm_searchsurfaced routine OS/Defender DNS lookups alongside a credential-dumping event where userfrank.kolzigexecutedntdsutil.exeonactivedir.stackedpads.local(10.1.0.4).Triage metadata: The
ntdsutil.exeevent is retained withseverity_score: 3.95 / 5.0(severity: 4, High Severity),79.96%true-positive probability,mitre_tactic: "credential_access", andnext_action: "escalate_tier2".
Figure 2. Live A2A trace against the deployed soc_orchestrator showing threat_hunter retrieving replayed RULES_SEARCH_WORKSHOP events and retaining the ntdsutil.exe activity (3.95 / 5.0, 79.96% TP, Credential Access, escalate_tier2).#
Figure 3. Calibrated probability distributions (noul, choice.probabilities, and score levels) produced by gemini-decision-1 without generating output tokens.#
Sanitized POST /v1beta/decisions request and response#
Sanitized batched request (_evaluate_batch with e0_* questions)#
{
"model": "gemini-decision-1",
"input": "Evaluate each numbered Chronicle SIEM UDM event or alert below:\n\n[Event 0]\n{\"dataset\":\"RULES_SEARCH_WORKSHOP\",\"event_id\":\"sysmon-ntdsutil-004\",\"log_type\":\"WINDOWS_SYSMON\",\"principal\":{\"hostname\":\"activedir.stackedpads.local\",\"ip\":\"10.1.0.4\",\"user\":{\"userid\":\"frank.kolzig\"}},\"target\":{\"process\":{\"command_line\":\"ntdsutil.exe \\\"ac i ntds\\\" \\\"ifm\\\" \\\"create full c:\\\\temp\\\\ntds_dump\\\" q q\",\"file\":{\"full_path\":\"C:\\\\Windows\\\\System32\\\\ntdsutil.exe\"}}}}",
"questions": {
"e0_sev": {
"type": "score",
"instructions": "For [Event 0], score the overall security severity of this Chronicle SIEM alert or UDM event.",
"criteria": [
"Informational or benign activity with no security impact.",
"Low severity anomaly or policy notice requiring routine review.",
"Medium severity suspicious activity warranting analyst investigation.",
"High severity likely threat activity with potential host or account impact.",
"Critical severity active compromise, lateral movement, or data exfiltration."
]
},
"e0_tp": {
"type": "noul",
"instructions": "For [Event 0], determine whether this alert or UDM event represents a true positive security threat rather than benign administrative activity or a false positive."
},
"e0_tactic": {
"type": "choice",
"instructions": "For [Event 0], select the primary MITRE ATT&CK tactic represented by this alert or UDM event.",
"criteria": {
"initial_access": "Phishing, exploit public-facing application, or external remote service entry.",
"execution": "Command and scripting interpreter, PowerShell, WMI, or malicious binary execution.",
"persistence": "Scheduled tasks, registry run keys, new accounts, or startup modifications.",
"privilege_escalation": "Token manipulation, sudo abuse, UAC bypass, or elevation to admin or SYSTEM.",
"defense_evasion": "Log clearing, process hollowing, disabling security tools, or obfuscation.",
"credential_access": "LSASS dumping, brute force, Kerberoasting, or credential harvesting.",
"discovery": "Network scanning, account or domain enumeration, or host reconnaissance.",
"lateral_movement": "SMB, WinRM, RDP, or SSH pivoting or remote service execution across hosts.",
"collection_exfiltration": "Staging archives, unusual outbound transfers, or DNS or HTTP exfiltration.",
"command_and_control": "Beaconing, C2 callbacks, or anomalous external encrypted channels.",
"other_or_benign": "Other tactic not listed above, or benign or inconclusive activity."
}
},
"e0_next": {
"type": "choice",
"instructions": "For [Event 0], select the recommended next SOC triage action for this alert or UDM event.",
"criteria": {
"dismiss": "Benign or clear false positive; close or deprioritize without further escalation.",
"enrich_cti": "Suspicious indicators present; enrich IPs, domains, or hashes via CTI before escalating.",
"escalate_tier2": "High-confidence threat or active compromise; escalate to Tier 2 for containment.",
"tune_yaral2": "Noisy or overly broad Chronicle SIEM YARA-L 2.0 detection rule (distinct from standard file/payload YARA); send to Detection Engineering for tuning."
}
}
}
}
Sanitized batched response (_evaluate_batch)#
{
"answers": {
"e0_sev": {
"type": "score",
"score": 2.95,
"confidence": 0.8412
},
"e0_tp": {
"type": "noul",
"noul": 0.7996,
"confidence": 0.7996
},
"e0_tactic": {
"type": "choice",
"choice": "credential_access",
"confidence": 0.9145,
"probabilities": {
"credential_access": 0.9145,
"execution": 0.0482,
"privilege_escalation": 0.0211,
"discovery": 0.0094,
"other_or_benign": 0.0068
}
},
"e0_next": {
"type": "choice",
"choice": "escalate_tier2",
"confidence": 0.8834,
"probabilities": {
"escalate_tier2": 0.8834,
"enrich_cti": 0.0891,
"tune_yaral2": 0.0182,
"dismiss": 0.0093
}
}
},
"usage": {
"promptTokenCount": 412,
"candidatesTokenCount": 0,
"totalTokenCount": 412
}
}
_evaluate_batch shifts answers.e0_sev.score (2.95) by +1.0 to 3.95 (severity: 4), keeps the event because 0.7996 >= 0.30, and attaches decision1_triage before passing the filtered list (plus any passthrough_overflow_count items beyond 60 events or 15 seconds) to threat_hunter_llm.
See Gemini Decision 1 for Governed SOC Agents for the full architecture and Case Study: Single-Pass Pre-Flight Short-Circuit and Pre-LLM UDM Filtering for the end-to-end soc_orchestrator walkthrough.