mlsanityData to 14 Oct 2026

Self-Reflection Fine-Tuning: Enhancing Agent Security against Prompt Injection Attacks from Failure Experience

arXiv 2610.04269 ↗First posted 3 Oct 2026cs.LG cs.CRcited by 0

On the map: LLM agents and tool use → Agent threats, guardrails and governance

also in 1 more
Abstract (arXiv)

Large language model (LLM) agents are increasingly deployed in tool-augmented environments, but their reliance on external inputs makes them highly vulnerable to prompt injection attacks that can hijack task objectives. Existing safety alignment methods rely on static expert trajectories or preference optimization, limiting their ability to generalize to adaptive attack patterns. In this work, we propose Self-Reflection Fine-Tuning (SRFT), a training framework that enables agents to improve robustness by learning from their own failure experiences under adversarial conditions. Instead of passively imitating expert behaviors, SRFT exposes the agent to compromised trajectories constructed via injected attacks, and leverages an expert model to generate structured self-reflection reasoning that contrasts unsafe and optimal actions. This reflective supervision teaches the agent to identify malicious instructions, reason about their consequences, and maintain alignment with the original user intent. We instantiate this framework in SR-Agent, built on Llama-3.1-8B-Instruct and Qwen3-8B, and evaluate it on both static and adaptive prompt injection benchmarks. Experimental results show that SRFT substantially reduces attack success rates while preserving task performance, and demonstrates strong generalization under adaptive attacks. These findings suggest that learning from failure via self-reflection is a promising direction for building robust and secure LLM agents. Our code is released at https://github.com/Eden-Wang1710/srft-repo.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 32 of its 41 references that are in the map. First posted on arXiv 3 Oct 2026.

Builds on

32 of 41 references.

Closest ancestors · 6

Same direction, newest first

  1. 2026ReasAlign: Reasoning Enhanced Safety Alignment against Prompt Injection Attack15 Jan
  2. 2025RL Is a Hammer and LLMs Are Nails: A Simple Reinforcement Learning Recipe for Strong Prompt Injection6 Oct
  3. 2025DRIFT: Dynamic Rule-Based Defense with Injection Isolation for Securing LLM Agents13 Jun
  4. 2025Defeating Prompt Injections by Design24 Mar
  5. 2024IsolateGPT: An Execution Isolation Architecture for LLM-Based Agentic Systems8 Mar
  6. 2024InjecAgent: Benchmarking Indirect Prompt Injections in Tool-Integrated Large Language Model Agents5 Mar

Other references · 26

  1. 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,380
  2. 2020Measuring Massive Multitask Language Understandingcited by 7,963
  3. 2023Toolformer: Language Models Can Teach Themselves to Use Toolscited by 4,182
  4. 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,807
  5. 2024SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineeringcited by 1,737
  6. 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,651
  7. 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injectioncited by 1,443
  8. 2023Jailbreaking Black Box Large Language Models in Twenty Queriescited by 1,420
  9. 2023Mind2Web: Towards a Generalist Agent for the Webcited by 1,242
  10. 2023Instruction-Following Evaluation for Large Language Modelscited by 1,228
  11. 2023Llama Guard: LLM-based Input-Output Safeguard for Human-AI Conversationscited by 1,207
  12. 2024OSWorld: Benchmarking Multimodal Agents for Open-Ended Tasks in Real Computer Environmentscited by 1,195
14 more
  1. 2024OpenHands: An Open Platform for AI Software Developers as Generalist Agentscited by 1,002
  2. 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 832
  3. 2023Tree of Attacks: Jailbreaking Black-Box LLMs Automaticallycited by 672
  4. 2023Baseline Defenses for Adversarial Attacks Against Aligned Language Modelscited by 651
  5. 2023SmoothLLM: Defending Large Language Models Against Jailbreaking Attackscited by 469
  6. 2025RAGEN: Understanding Self-Evolution in LLM Agents via Multi-Turn Reinforcement Learningcited by 386
  7. 2024StruQ: Defending Against Prompt Injection with Structured Queriescited by 375
  8. 2023NeMo Guardrails: A Toolkit for Controllable and Safe LLM Applications with Programmable Railscited by 365
  9. 2023Exploiting Programmatic Behavior of LLMs: Dual-Use Through Standard Security Attackscited by 278
  10. 2024Defending Against Indirect Prompt Injection Attacks With Spotlightingcited by 267
  11. 2024SecAlign: Defending Against Prompt Injection with Preference Optimizationcited by 210
  12. 2024OS-Copilot: Towards Generalist Computer Agents with Self-Improvementcited by 205
  13. 2025DataSentinel: A Game-Theoretic Detection of Prompt Injection Attackscited by 143
  14. 2026AgentDyn: Are Your Agent Security Defenses Deployable in Real-World Dynamic Environments?cited by 59

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2026RAISED: Self-Distillation for Robustness to Prompt Injection in LLM Agents
  2. 2026Defending against Adaptive Prompt Injection Attacks via Reasoning-enabled Task Alignment
  3. 2026Toward Metacognitive One-Shot Indirect Prompt Injection: Strategy Abstraction Via Outcome-Conditioned Reflection
  4. 2026OEP: Poisoning Self-Evolving LLM Agents via Locally Correct but Non-Transferable Experiences
  5. 2026The Autonomy Tax: Defense Training Breaks LLM Agents
  6. 2026SkillSafetyBench: Evaluating Agent Safety under Skill-Facing Attack Surfaces
  7. 2026IterInject: Indirect Prompt Injection Against LLM Agents via Feedback-Guided Iterative Optimization
  8. 2025Agent Safety Alignment via Reinforcement Learning