# BlueCodeAgent: A Blue Teaming Agent Powered by Automated Red Teaming for CodeGen AI

DevFeed: [BlueCodeAgent: A Blue Teaming Agent Powered by Automated Red Teaming for CodeGen AI](<https://devfeed.tech/articles/bluecodeagent-a-blue-teaming-agent-powered-by-automated-red-teaming-for-codegen-ai-107329.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2510.18131>)

Author: Chengquan Guo, Yuzhou Nie, Chulin Xie, Zinan Lin, Wenbo Guo, Bo Li

Published: 2026-10-30T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [vulnerability scanning](<https://devfeed.tech/topics/vulnerability-scanning.md>), [Artificial Intelligence](<https://devfeed.tech/topics/ai.md>), [Fuzzing/Fuzz testing](<https://devfeed.tech/topics/fuzzing.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-security](<https://devfeed.tech/tags/ai-security.md>), [codegen](<https://devfeed.tech/tags/codegen.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [defense](<https://devfeed.tech/tags/defense.md>), [detection](<https://devfeed.tech/tags/detection.md>), [evaluation](<https://devfeed.tech/tags/evaluation.md>), [red-teaming](<https://devfeed.tech/tags/red-teaming.md>), [risk](<https://devfeed.tech/tags/risk.md>)

## AI overview

BlueCodeAgent uses automated red teaming to generate risky code-related examples that guide a blue-team agent's defenses. The agent summarizes actionable constitutions and applies dynamic code analysis to detect known and unseen risks across bias instruction, malicious instruction, vulnerable code, and prompt injection detection. The abstract reports that, with GPT-4o, it improved average F1 by 14.7% over direct prompting across these four tasks. For vulnerability detection, dynamic analysis reduced false positives, which the abstract says base models tend to produce through over-conservative judgments.

## Source excerpt

arXiv:2510.18131v2 Announce Type: replace Abstract: Existing research on CodeGen AI security mainly focuses on red teaming, which aims to uncover vulnerabilities and risks in AI-generated code. However, progress on the blue teaming side remains limited, as effective defenses require a deep security analysis of given tasks and edge cases. To fill in this gap, we propose BlueCodeAgent, an end-to-end blue teaming agent powered by automated red teaming. Our red teaming component generates diverse risky instances, providing effective edge cases and guidance for the subsequent blue teaming process. Our blue teaming agent then conducts multi-level defense, leveraging these red teaming examples to detect previously seen and unseen risk scenarios through constitution summarization and dynamic code analysis. Our evaluation across four representative code-related tasks (bias instruction detection, malicious instruction detection, vulnerable code detection, and prompt injection detection) shows that BlueCodeAgent achieves significant gains over diverse baselines. In particular, for vulnerability detection tasks, BlueCodeAgent integrates dynamic analysis to effectively reduce false positives, a challenging problem as base models tend to be over-conservative. Overall, with GPT-4o as the base model, BlueCodeAgent achieves an average F1 score improvement of 14.7% across four tasks compared to directly prompting the model, attributed to its ability to summarize actionable constitutions and perform dynamic analysis. Our code and data are available at https://github.com/1mocat/BlueCodeAgent.