Constraint Decay: The Fragility of LLM Agents in Back End Code Generation
TL;DR Highlight
Stacking structural constraints cut coding agents' assertion pass rate by 27.28 points on average.
Who Should Read
Backend developers who hand framework, ORM and architecture-constrained code to coding agents like Claude Code or Codex
Core Mechanics
- Pass rates fall as constraints pile up
- Agent performance dropped sharply as structural requirements accumulated, which the paper calls constraint decay.
- Evaluated configurations lost 27.28 points on average in assertion pass rate from baseline to fully specified tasks.
- 80 greenfield plus 20 feature tasks
- The study fixed one API contract across 80 greenfield tasks and 20 feature-implementation tasks on eight web frameworks.
- It used end-to-end behavioral tests plus static verifiers.
- Frameworks change the result
- Mid-tier models succeeded in minimal, explicit frameworks like Flask.
- They did substantially worse on average in convention-heavy ones like FastAPI and Django.
- Data layer causes most failures
- Incorrect query composition and ORM runtime violations were the leading root causes.
- Meeting function and structure together is still hard
- The authors call it a key open challenge for coding agents.
- They say existing benchmarks reward functionally correct but structurally arbitrary solutions.
Community Reactions
- Frontier models were not fully tested for cost reasons
- A commenter says the specific numbers deserve a grain of salt.
- They still find the conclusion interesting that models degrade when behavior and architecture must both be right.
- Only GPT-5.2 was used, not a coding-tuned model
- One commenter found it odd that GPT-5.2-codex was skipped.
- Another asked whether validation loops were included and how many turns it took to pass.
- Exemplar files and linters helped, per commenters
- One said @-referencing a few idiomatic files worked better than steering with markdown.
- Another suggested architecture linters like ArchUnit to feed violations back to the LLM.
- Some saw the opposite effect
- One commenter found patches got more accurate on bigger, older codebases.
- They said their agent makes over 100 sql and git tool calls before applying a patch.
How to Apply
- Turn architecture rules into lint tests
- Pick the 1-2 rules your agent breaks most, such as banned cross-layer imports, and encode them today.
- Make CI fail on violations instead of relying on markdown instructions.
- Give exemplar files with each task
- Choose one or two files where your conventions are followed well.
- @-reference them in new tasks and tell the agent to follow the same pattern.
- Put constraints in up front and test the data layer
- Include structural constraints in the first prompt instead of adding them later.
- Verify queries and ORM code with separate tests against a real DB.
Try It
# Paste into Claude Code or ChatGPT (simplified version of the paper's idea: constraint self-check)
Before implementing the backend task below, rewrite the structural constraints as a numbered list.
[Task]
{{feature to implement}}
[Structural constraints]
- Framework: {{e.g. FastAPI}}
- ORM/DB: {{e.g. SQLAlchemy + PostgreSQL}}
- Architecture pattern: {{e.g. router-service-repository layers}}
Rules:
1. After implementing, mark each constraint PASS/FAIL, citing file and function names as evidence.
2. Check query construction and ORM session usage separately.
3. If anything is FAIL, fix it and check again.Terminology
Related Papers
Gemini 4 Neon is the new #1 on the Models Engineering Index
Gemini 4 Neon ranks first on the Models Engineering Index with 68.0, combining multiple benchmarks.
LLMs can read and write executables byte by byte from a hex dump
Given only a hex dump and no tools, an LLM analyzed, patched and wrote working executables.
Claude was trained on protein sequences at scale
Next-amino-acid tests on obscure proteins show only the latest Claude models predict them
Remembered as Brief: Stored Preferences SilentlyRemove Decision-Critical Information
A stored 'keep it short' preference silently drops warnings; listing must-know points first restores content.
All AI-generated code should be Open Source
A blog argues AI-generated code should be open source; most HN commenters disagreed.
What thousands of conversations look like inside a language model
Mapping Qwen3-1.7B states showed Chinese sitting apart from English, while German and Croatian overlapped it.
AI, activity, and outcomes in software engineering
AI sped up writing code, but shipping speed did not rise as much, says a talk
LLMs Play Zachtronics' TIS-100
16 LLMs played TIS-100 and set 133 new Pareto frontier points across 18 puzzles