Manuscript Offprint

arXiv:2610.17488

Origin Attribution for Unsafe Behavior in Self-Evolving Multi-Agent Coding Systems

Hanyi Yu, Jiaming Cui

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Hanyi Yu 1^{1} Jiaming Cui 2^{2}

1^{1}University of Southern California, Los Angeles, CA

2^{2}Virginia Tech, Blacksburg, VA

hanyiyu@usc.edu, jiamingcui@vt.edu

As language-model-based coding agents evolve their programs and reuse code from one another, safety failures can acquire a history that extends beyond the agent in which they are detected. An unsafe change may originate in one agent, propagate through intermediate recipients, and survive subsequent revisions before an audit reveals it. Understanding this history is important for identifying the introducing change and distinguishing inherited behavior from independently occurring failures. We study origin attribution in self-evolving multi-agent coding systems: recovering the agent and program version that introduced an observed unsafe behavior into the target's code lineage, or determining that it arose locally. This task is challenging because rewriting obscures textual similarity, independent occurrences confound temporal ordering, and intermediate recipients can resemble the source. We propose a method that combines behavioral fingerprint matching with historical localization and recursive tracing. It compares candidate implementations beyond the unsafe outcome, retains evidence from multiple historical versions, and follows matching candidates upstream. On 158 queries across 85 controlled scenarios, the method achieves 96.8% exact attribution accuracy, compared with 77.2% for exhaustive fingerprint matching without recursion. Component ablations and evaluation on 34 additional queries using the same method and hyperparameters demonstrate the complementary roles of multiple representatives and recursive tracing. Further checks extend the evaluation to approval-boundary and resource-owner errors. Together, these results show how behavioral and historical evidence can recover the origins of unsafe behavior through code revision and cross-agent propagation. Code is available here.

1 Introduction

Language-model-based coding agents increasingly revise their own programs and reuse code from other agents. These capabilities can also preserve and spread unsafe behavior. Studies of self-evolving agents show that successful task performance can coexist with safety degradation [17, 28]: a customer-service agent, for example, approved an improper refund, received a high rating, and subsequently treated refunds as a way to earn high ratings [17]. Unsafe experience may persist as reusable procedures [11], while cross-agent sharing can propagate compromised components through a population [9].

Once an audit detects such behavior, identifying the affected agent is only the starting point. The introducing change may lie in another agent's history and may have passed through several recipients before reaching the audited version. Prior work calls for attributing safety degradation to specific evolutionary events [9], and shared-memory research identifies lost artifact provenance as an obstacle to tracing reuse [12]. We therefore ask: which agent, at which version, introduced the unsafe behavior into the target's code lineage?

Answering this question requires distinguishing inheritance from resemblance. Rewriting can obscure textual similarity, while independently introduced failures can share an unsafe outcome. Code-completion studies also show that generated code can reproduce historical bugs [4]. Even a matching

Figure

Figure 1. Environment and attribution task (illustrative history). D⋅v2D \cdot v_2 propagates through A⋅v3A \cdot v_3 to C⋅v4C \cdot v_4; C⋅v5C \cdot v_5 is audited after further revision. B⋅v2B \cdot v_2 is an earlier independent occurrence. Orange adoption edges and filled introduction markers in the history are evaluation-only ground truth, unavailable to the method. Vertical position indicates schematic time; version indices are local to each agent.

donor may be an intermediate recipient rather than the origin. These ambiguities connect agent failure attribution [27, 25] with software-history analysis [19], but arise across persistent code-adoption histories rather than a single execution trace.

Our method follows this historical structure. It anchors the audit at an early unsafe target version, compares candidate code on behavior beyond the failure itself, and traces matching candidates toward earlier versions in other agents. Multiple representatives retain evidence from both unsafe onset and later revisions. Behavioral compatibility identifies plausible candidates, while historical localization and recursive tracing seek the introducing event behind later revisions and intermediate recipients. The method uses archived code and timestamps, with adoption records reserved for evaluation.

We contribute an origin-attribution task and controlled benchmark, together with a method for tracing unsafe behavior through revision and adoption. The evaluation systematically varies rewriting, independent occurrences, and propagation, and shows how behavioral matching and historical tracing jointly improve source recovery.

References (27)