Variable Aggression Code Autocomplete with Fine-Tuned LLMs
windsurf · Tech · 2026 · source Agentic: no · promotional bias: med · source-backed · extracted with prompt 0.5.6 (schema v2)
Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.
Problem
Domain: AI code autocomplete
Windsurf needed to improve code autocomplete by saving more real developer keystrokes rather than merely optimizing acceptance rate on safe, short suggestions.
Constraints:
- Autocomplete runs on every keypress, so prompt length, latency, and cost matter.
- Acceptance rate can reward trivial predictions that add little value.
- Users have heterogeneous preferences for how much code the model should predict.
- RL reward functions can be hacked by code models optimizing for runnable code rather than developer intent.
- Incorrect aggressive suggestions may impose cognitive overhead.
Architecture
Windsurf rebuilt Tab v2 around context engineering, RL training, and user-selectable aggression. The team shortened the autocomplete prompt by 76%, removed irrelevant Cascade/tool context, added useful related-file and cursor context, rebuilt training data around production context, trained models with RL for different aggression levels, evaluated prediction frequency, acceptance, characters per prediction, and accepted characters, and exposed aggression as a configurable product parameter.
Diagram confidence: explicit (topology described by the source).
flowchart LR editor-keypress-stream["Editor keypress stream"] --> context-engineering-layer["Context engineering layer"] context-engineering-layer --> tab-v2-model["Tab v2 model"] tab-v2-model --> aggression-controller["Aggression controller"] aggression-controller --> user-preference-settings["User preference settings"] tab-v2-model --> rl-training-pipeline["RL training pipeline"] rl-training-pipeline --> evaluation-and-ab-testing["Evaluation and AB testing"] evaluation-and-ab-testing --> user-preference-settings
Components
| Component | Role | Interacts with |
|---|---|---|
Editor keypress stream |
Triggers autocomplete predictions during coding. | Context engineering layer |
Context engineering layer |
Builds compact, task-specific model context from cursor, related files, and prompt instructions. | Editor keypress stream, Tab v2 model |
Tab v2 model |
Generates autocomplete, multi-line, navigation, and import predictions. | Context engineering layer, Aggression controller |
Aggression controller |
Adjusts prediction length/risk according to user-selected aggression level. | Tab v2 model, User preference settings |
User preference settings |
Let developers choose the autocomplete aggression level. | Aggression controller |
RL training pipeline |
Trains autocomplete behavior and aggression levels against reward/evaluation data. | Tab v2 model, Evaluation and AB testing |
Evaluation and AB testing |
Measures prediction frequency, acceptance rate, characters per prediction, accepted characters, and user interviews. | RL training pipeline, User preference settings |
Data flow
On each editor keypress, Tab gathers optimized code context, related files, cursor information, and prompt instructions, sends them to a fine-tuned autocomplete model, and returns code predictions at a user-selected aggression level. Production metrics and interviews feed evaluation, RL reward design, A/B testing, and future model improvements.
3 supporting quotes
Why this architecture
Windsurf optimized for total accepted code rather than raw acceptance because safe, short suggestions can look good in metrics while saving little work. Aggression became configurable because the same model behavior was too bold for some developers and too timid for others.
Models used: Fine-tuned code autocomplete LLM · Reinforcement learning training pipeline
Scale
- The team analyzed billions of production predictions.“After analyzing billions of predictions in production”summary, stated
- System prompt prefix length was reduced by 76%.“they achieved a 76% reduction in system prompt prefix length.”summary, stated
- Characters per prediction increased by 54% on average.“The headline result was an average 54% increase in characters per prediction while maintaining comparable acceptance rates.”summary, stated
- Accepted code improved by 25-75% depending on aggression level.“The final results show the impact of this approach: 25-75% more accepted code depending on the chosen aggression level.”summary, stated
Alternatives considered (roads not taken)
Optimize raw acceptance rate
Rejected because: Acceptance rate can be gamed by making only obvious, low-value suggestions.
Reuse Cascade's system prompt
Rejected because: Cascade context was unoptimized and poisoned the autocomplete task.
Choose one aggression level for all users
Rejected because: User interviews showed the same behavior felt too aggressive to some and not bold enough to others.
Patterns
context-engineering (prompting)
Windsurf removed irrelevant prompt/tool context, shortened the prompt by 76%, and added task-specific cursor/related-file context.
fine-tuning-adaptation (model training)
Tab v2 uses RL-trained autocomplete behavior and aggression levels informed by production context data.
eval-driven-development (product metrics)
The team redefined success around keystrokes saved, A/B tested Pareto improvements, and added qualitative interviews to catch preference variance.
data-quality-loop (training feedback)
Production data, reward-hack discoveries, and interviews feed model and reward-function improvements.
Tradeoffs
User-selectable aggression
Chose Let developers choose prediction boldness over Optimize one model setting for the median user.
Rationale: The same autocomplete behavior creates different value and annoyance for different users.
Shorter task-specific context
Chose Remove irrelevant prompt/tool instructions over Reuse a broad product prompt from Cascade.
Rationale: Shorter context reduced cost/latency and improved autocomplete-specific performance.
Gotchas (what bit them)
Acceptance rate rewards trivial suggestions.
Root cause: A model can improve acceptance by predicting only obvious, short completions.
Resolution: Windsurf optimized accepted characters/keystrokes saved while holding prediction frequency constant.
Code RL reward functions can learn the wrong behavior.
Root cause: Standard code-model post-training assumes code should be runnable, but autocomplete often happens in incomplete intermediate states.
Resolution: Windsurf invented new evaluations to capture high-quality aggression instead of runnable-code restoration.
Aggregate A/B metrics can hide user preference heterogeneity.
Root cause: Different developers want different autocomplete boldness.
Resolution: Windsurf exposes aggression levels for users to choose.
Evaluation
Windsurf evaluates autocomplete with prediction frequency, acceptance rate, characters per prediction, total accepted characters, A/B tests, and qualitative interviews.
Metrics: 76% prompt prefix reduction · 54% average increase in characters per prediction · 25-75% more accepted code · Prediction frequency · Acceptance rate
Outcomes
- System prompt prefix length fell by 76%.
- Characters per prediction increased by 54% on average.
- Accepted code increased by 25-75% depending on aggression level.
- User preference heterogeneity became an explicit product control.
The system was rebuilt after analyzing billions of production predictions, with autocomplete triggered on every keypress.