Skip to content

SWE-2 verbatim repetition loops on long agentic trajectories (native Devin CLI) #7

Description

@future3OOO

SWE-2 falls into verbatim-repetition attractors during long agentic sessions — both inside a single generation and across turns after context compaction. Observed on pure native Devin CLI (devin --model swe-2-max), no proxy or third-party client involved.

Environment

  • devin CLI, model swe-2-max, session false-margin (2026-09-12)
  • Workload: multi-hour implementation task on a Python repo (sqlite-utils), using skills/hooks, ~220 tool calls, several context compactions
  • Sampling config on the wire: temperature=1.0, top_p=0.95, top_k=40 — client-exposed defaults; no repetition/frequency penalty mechanism exists

Symptom 1 — intra-generation paragraph loop

A single thinking stream repeated a ~600-word paragraph byte-for-byte, twice in one generation:

The core issue is whether to modify `insert_chunk`'s transaction handling or
stick with snapshots. [...] This avoids copying the whole DB into memory,
which feels more aligned with the user's implied preference for transaction
semantics over snapshots.

The core issue is whether to modify `insert_chunk`'s transaction handling or
stick with snapshots. [...] (same ~600-word block repeated verbatim)

At t=1.0 a byte-identical ~2KB span has no plausible sampling explanation other than a decode attractor: once generated, the paragraph's presence in-context raises its own probability mass.

Symptom 2 — post-compaction re-emission

In the session's message_nodes, identical assistant narration texts recur across branch boundaries, and every genuine cross-branch re-emission clusters immediately after compaction/resume nodes (~8 instances). The model re-emits and re-executes work the compacted context presents as uncommitted — e.g., re-attempting identical edits that then fail with "string not found" because they already applied.

Why this is server-side

No client input causes a model to byte-copy a 2KB paragraph inside one stream. Client-side mitigations can only reduce how much verbatim prior text sits in context; they can't touch the attractor itself.

Suggested mitigations

  1. Repetition/frequency penalty (or anti-loop n-gram blocking) in the planner's sampler for long trajectories.
  2. A stream-time verbatim detector: if a generated span byte-matches an earlier in-context span beyond a threshold, truncate and resample.
  3. Compaction summaries that carry explicit per-step action state ("done/pending"), so post-compaction context doesn't present finished work as outstanding.

Happy to share the session transcript extract and the verbatim block in full.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions