arXiv:2611.05088cs.AINov 2026

Manuscript Offprint

arXiv:2611.05088

LatentTriad: Pre-Action Risk Representations for Malicious Agent Skill Detection

Zhe Yu, Yi Liu, Ying Zhang, Simin Chen

ABSTRACT

Large language model agents are increasingly extended with reusable skills, but untrusted skill content can induce operations outside the user's task. Detecting this contextual risk requires more than suspicious-pattern matching, while dynamic analysis incurs the cost of skill execution. We find that hidden states formed during prefill contain readable information about task–operation consistency, including across held-out expression forms in controlled evaluations. Matched Operation-state interventions also affect later Boundary states and shift fixed risk readouts toward the donor label. Based on these findings, we introduce LatentTriad, which combines contextual Boundary features, group-adjusted Operation directions, and departures from benign state relationships. All branches share one prefill: detection generates no output tokens, invokes no tools, and executes no skill code. Across 5,830 skill packages from five sources and seven backbones, LatentTriad achieves 99.0–99.2% pooled F1 and 93.0–94.6% source-macro F1. A separately measured compact implementation completes prefill and detection in a median of 259–284 ms. These results connect pre-action risk readability and functional influence to execution-free skill screening.

1 INTRODUCTION

Large language model (LLM) agents are increasingly extended with reusable skills: packages of instructions, scripts, and configurations that provide specialized capabilities. Public skill ecosystems are already large; for example, SkillsMP indexes over 3.18 million public SKILL.md files. However, loading untrusted skills also creates a security risk: their instructions and executable components can steer an agent toward operations that violate the user's trusted task.

Detecting such behavior is difficult because skill risk is context-dependent and may be distributed across multiple components. Instructions, scripts, and configurations that appear benign in isolation may jointly induce an unauthorized operation, while sensitive operations such as file or network access can be legitimate when required by the task. Static rules based on keywords or code patterns therefore struggle to capture behavioral intent. Dynamic analysis provides stronger behavioral evidence, but requires generation, sandbox execution, and runtime monitoring, making it expensive for large-scale screening.

This raises a central question: can malicious behavior be detected after the model has interpreted a skill, but before it generates or executes an action?

We find that hidden states formed during prefill already contain information useful for determining whether a prospective operation is consistent with the trusted task. This information remains predictive when the same behavior is expressed in unseen forms. Moreover, controlled state interventions show that changing representations associated with skill operations can alter later model states and risk predictions. These results suggest that pre-action representations provide a useful middle ground between surface-level static inspection and costly execution-based analysis.

Figure

Figure 1: LatentTriad overview. One prefill of the task and skill yields Declaration, Operation, and Boundary states for risk detection. Connections show schematic feature flow; the right panel illustrates optional source attribution.

Based on these findings, we introduce LatentTriad, a pre-action detector that probes hidden representations while an agent processes the trusted task and candidate skill. From one prefill, a Boundary branch reads the complete context, an Operation branch projects operational states onto learned risk directions, and a Geometry branch measures departures from benign relationships among the skill's stated purpose, operations, and context. LatentTriad generates no output tokens, invokes no tools, and executes no skill-provided code.

We evaluate LatentTriad on 5,830 skill packages from five source datasets across seven model backbones. LatentTriad achieves 99.0–99.2% pooled F1 and 93.0–94.6% source-macro F1. Cross-form evaluations show that risk information generalizes to unseen expressions, while controlled interventions show that changing Operation states can affect later representations and risk-related decisions. Separately, a compact configuration completes prefill and detection in 259–284 ms median latency, compared with approximately 153 s per skill reported by the sandbox-based SkillDetonate.

Our contributions are:

  • We identify task-conditioned risk information in pre-action hidden states. Controlled cross-form tests establish its readability, while matched state interventions show effects on later states and fixed risk readouts.

  • We introduce LatentTriad, combining a contextual Boundary readout, group-adjusted Operation risk directions, and Geometry residuals against benign reference maps. All three branches share one prefill.

  • We evaluate LatentTriad on 5,830 skill packages from five source datasets across seven backbones, achieving 99.0–99.2% pooled F1 and 93.0–94.6% source-macro F1. Source-holdout and composition studies test how detection changes across ecosystems and task-dependent skill combinations.

References (20)