arXiv:2610.07386cs.CROct 2026

Manuscript Offprint

arXiv:2610.07386

NetAgent: Multi-Task Agentic Network Traffic Analysis Made Practical

Hao Fu, Dawn Song, Peng Gao

Abstract

Network traffic analysis is central to network security, spanning tasks from intrusion detection to encrypted traffic classification. Existing approaches either train task-specific models that generalize poorly or rely on costly traffic foundation models that still struggle under distribution shift. We present NetAgent, the first agentic framework for multi-task traffic analysis. Through a carefully designed agent loop, NetAgent supports complex task understanding, on-the-fly decomposition and orchestration, dynamic replanning, and long-horizon analysis, without task-specific training. It introduces five key designs: (1) knowledge-augmented workflow planning that maps attack knowledge to traffic features to bridge the semantic gap; (2) a comprehensive tool action space with 150+ verified tools extracted from 50+ published systems; (3) a unified code execution space for flexible action composition; (4) a three-tier memory for long-term knowledge consolidation; and (5) sandboxing and runtime repair for reliable execution.

Across 9 major benchmarks, NetAgent outperforms all baselines (23 single-task and 5 multi-task) on nearly all tasks and generalizes substantially better to unseen traffic distribution (90.04% F1 vs. 2.74% and 3.04% for the best single-task and multi-task baselines) and under realistic background shift (4.85-point F1 drop vs. 74.88-point and 74.80-point drop for the best single-task and multi-task baselines). These results reveal that existing methods owe much of their reported success to overfitting dataset-specific patterns and degrade sharply in realistic network environments, while NetAgent's agentic design remains accurate, generalizable, and robust.

1 Introduction

Network traffic analysis examines network communication data across diverse tasks such as intrusion detection [18], malicious traffic detection [19], and encrypted traffic classification [64]. A security operations center (SOC) often handles many of these tasks and synthesizes their results into conclusions. Existing methods typically train a separate machine learning model per task, using tree-based classifiers over flow statistics [40], Graph Neural Networks (GNNs) over flow interactions [19], or transformers over packet sequences [35]. This per-task paradigm limits knowledge transfer and composability across tasks, and every new task requires fresh annotation and retraining.

Two lines of work aim to unify traffic analysis tasks. nPrint [21] automates per-task model training with AutoML, but still produces isolated models and is limited to shallow classifiers without deep traffic understanding. TrafficFormer [74] pre-trains a large transformer and fine-tunes it for downstream tasks, but pre-training is costly, fine-tuning requires substantial task-specific labels, and the model remains vulnerable to distribution shift. Our experiments (Section 4.4) show that TrafficFormer suffers an F1 drop of over 61.2 points under distribution shift. Moreover, such monolithic models map inputs to labels in a single forward pass and cannot decompose complex analyses into coordinated subtasks.

We argue that traffic analysis calls for a new paradigm that delivers complex task decomposition, orchestration, and generalization. Consider auditing an enterprise network. The analyst may first classify encrypted traffic by application to filter out known applications, then run tunnel detection on the remaining unattributed flows to identify covert channels such as DNS tunnels, and finally analyze all traffic from hosts using those channels for malicious activity to determine whether they are compromised. These tasks build on one another and require coordination as an integrated workflow, which no individual model can provide.

Large language models (LLMs) are a natural foundation for this paradigm: they bring broad attack knowledge from pretraining, can interpret analyst intent, and reason over data without task-specific training. However, LLMs alone lack awareness of the live network environment and are limited in complex task planning and execution. LLM-based agents address these limits by placing the LLM with its environment: an agent decomposes analyst queries, invokes diverse tools for processing, and synthesizes multi-task results through LLM reasoning.

Such agents have shown strong performance in domains like software engineering [22, 61] and biomedical research [23], yet no unified agent for multi-task traffic analysis has emerged.

Contributions. We present NetAgent, the first unified agentic framework for multi-task network traffic analysis. NetAgent structures traffic analysis into functional layers, from environmental perception to feature extraction, feature construction, and traffic classification, with uniform tool interfaces that enable flexible tool composition across layers. A carefully designed agent loop coordinates three agents, a planner, executor, and decision maker, to decompose an analyst query into orchestrated workflows, execute them, and decide whether to conclude or replan. Our key insight is that diverse traffic analysis tasks share reusable operations, such as packet parsing, feature extraction, traffic aggregation, and flow classification. By exposing these operations as atomic tools, NetAgent enables the agents to dynamically compose them into workflows for solving different traffic tasks.

NetAgent addresses key challenges specific to the traffic domain and makes the following technical contributions:

(1) An agent is only as capable as its action space, the set of tools through which it perceives and acts, yet no such space exists for traffic analysis. We thus construct a comprehensive tool action space with an LLM-driven discovery pipeline that mines reusable operations from 50+ published traffic analysis systems, yielding a library of 150+ verified tools, covering critical capabilities across diverse traffic analysis tasks.

(2) In the multi-task setting with diverse attack patterns, the agent must bridge the semantic gap between high-level attack knowledge and low-level traffic features. We introduce knowledge-augmented workflow planning. Traffic is normalized into a unified multi-view feature matrix, and an attack knowledge base expresses attack patterns as conditions over these features. For example, a long-lived connection with small packets and large inter-arrival times may indicate cryptomining. The planner retrieves relevant attack knowledge to augment workflow planning.

(3) Typical agents emit actions as text or JSON in a predefined format, which limits their ability to dynamically compose multiple tools and revise prior actions. NetAgent uses code as the composition medium. The executor maintains a persistent code space in which all tools are callable functions and each action is emitted as a code snippet that flexibly composes tools and passes results. Execution self-corrects using interpreter feedback.

(4) A long-horizon analysis must recover quickly from failures, as a single traffic data read error can cascade through subsequent steps and fail the entire analysis. The executor uses sandboxed execution, static error checks, and dynamic repair to re-execute only the minimal set of steps affected according to the dataflow dependencies.

(5) A long-horizon analysis must retain and reuse knowledge across tasks under continuous network drift. NetAgent maintains a three-tier memory that consolidates raw analysis conclusions into recurring behavior patterns and then into long-term knowledge. This layered consolidation compacts memory, enables knowledge reuse, and resolves drift-induced conflicts for history-aware decision making.

We evaluate NetAgent’s performance, generalizability, and robustness on 9 widely used benchmarks spanning diverse traffic analysis tasks (Table 2). We systematically compare NetAgent against 28 baselines: 23 single-task methods, including 7 classical ML and 16 SOTA deep learning methods (e.g., GNNs [19, 71], transformers [11, 35], autoencoders [44, 71]), and 5 multi-task methods, including nPrint [21], TrafficFormer [74], ET-BERT [35], TrafficLLM [8], and a ReAct agent [69] equipped with our tool library. The results show that:

(1) NetAgent delivers consistently strong performance across diverse traffic analysis tasks. It achieves the best performance on 8 of 9 tasks, outperforming all single-task and multi-task baselines with F1 above 98.63%. On VPN traffic classification, NetAgent achieves 92.42% F1, outperforming all single-task methods and all multi-task methods except ET-BERT (94.54% F1); however, NetAgent significantly exceeds ET-BERT by an average of 35.51 F1 points across the other 8 tasks.

(2) NetAgent generalizes substantially better to unseen traffic distribution. When baselines are trained on UNSW-NB15 and tested on the unseen CIC-IDS2017 dataset for web attack detection, the best single-task and multi-task baselines achieve only 2.74% and 3.04% F1, while NetAgent achieves 90.04%.

(3) NetAgent remains robust under realistic background distribution shift. After injecting 5×5 \times real-world MAWI/WIDE backbone traffic into the web attack detection test set, the best single-task and multi-task baselines lose 74.88 and 74.80 F1 points, while NetAgent drops by only 4.85 points.

These results demonstrate that prior methods often overfit dataset-specific patterns and degrade sharply in realistic network environments with background traffic noise and distribution shift, whereas NetAgent’s agentic design remains accurate, generalizable, and robust. Beyond these gains, the same design covers a broad range of traffic analysis tasks in one unified framework without task-specific training.

References (64)