How do ads get blended into the For You feed?

After your organic posts are ranked, a separate blender inserts ads into "safe gaps" between them — never adjacent to certain content, never closer together than a minimum spacing, and not at all until the feed has a minimum number of posts. Ads don't compete with your post for a ranking slot; they're placed into the gaps around already-ranked organic content. This is why ad load feels spaced rather than stacked, and why it matters that organic ranking happens first, independently.

A reasonable worry: do ads steal ranking slots from organic posts? The released code says no — not directly. Organic posts are ranked first, then a dedicated blender places ads into the spaces between them, under spacing rules.

Ads fill gaps, they don't compete for rank

The blender takes already-scored organic posts and a set of ads, finds the safe gaps, and assigns ads into them with computed spacing:

home-mixer/ads/safe_gap_blender.rs · L25–L28@ 0bfc279
25let safe_gaps = find_safe_gaps(&scored_posts);
26let spacing = compute_spacing(&ads);
27let first_ideal = ads[0].insert_position.max(0) as usize;
28let placements = assign_ads_to_gaps(&safe_gaps, ads.len(), &spacing, first_ideal);
CODE-CURRENT0bfc279verified 2026-06-12
Ads are blended into already-scored organic posts by a SafeGapAdsBlender: it finds 'safe gaps' between ranked posts, computes spacing, and assigns ads into those gaps — organic ranking happens first, then ads are placed into the spaces.
xai-org/x-algorithm — home-mixer/ads/safe_gap_blender.rs, blend_impl find_safe_gaps + assign_ads_to_gaps (L25-L28)as of the May 15, 2026 release

The key word is gaps. Your post earned its rank among organic candidates before any ad entered the picture; the ad is then slotted into a gap near a target position. Organic ranking and ad placement are two separate steps, in that order.

The spacing rules

Ad insertion is governed by constraints visible in the code: a minimum number of posts before ads appear at all (MIN_POSTS_FOR_ADS), a computed minimum spacing between ads, and "safe gap" logic that avoids placing an ad in an unsuitable spot. The blender searches for the best gap at or after each ideal position rather than forcing ads in at fixed intervals.

CODE-CURRENT0bfc279verified 2026-06-12
Ad insertion is constrained by a minimum number of posts before ads appear (MIN_POSTS_FOR_ADS), a computed minimum spacing between ads, and safe-gap selection that searches for the best eligible gap at or after each ideal position rather than forcing fixed intervals.
xai-org/x-algorithm — home-mixer/ads/safe_gap_blender.rs, MIN_POSTS_FOR_ADS + compute_spacing + find_best_gap (L10, L26, L72-L77)mechanism present; exact constants in withheld params as of the May 15, 2026 release

Signal by signal

in the codein plain english
organic ranked first, then blendedAds don't take a ranking slot from your post. Your rank is decided among organic posts before ads enter.
MIN_POSTS_FOR_ADSNo ads until the feed has enough organic posts — a sparse feed isn't front-loaded with ads.
safe gaps + spacingAds are spaced out and kept out of unsuitable positions, not stacked.

What the code doesn't say

▲ What the code doesn't say

The actual values: how many posts before the first ad, how wide the minimum spacing, what makes a gap "unsafe." These constants and the brand-safety rules behind them are not fully in the release. The architecture — rank organic, then blend ads into safe gaps — is code-current; the exact ad load is not.

UNKNOWN0bfc279verified 2026-06-12
The numeric values of the current weights are not included in the open-source release: weighted_scorer.rs references a params module (e.g. p::FAVORITE_WEIGHT, p::REPLY_WEIGHT) whose values are not present anywhere in the published repository.
xai-org/x-algorithm (verified by direct inspection of the full repository tree at the pinned SHA) — home-mixer/scorers/weighted_scorer.rs references crate::params; no params definitions with weight values exist in the releaseabsence verified at the pinned SHA; values may be published in a future release

What to do with this

Mostly, take reassurance from the architecture: ads are not why a given post underperformed — your post's rank was settled among organic candidates before ad placement. If reach is down, the answer is in the organic ranking and filter stages, not ad competition. That keeps the diagnosis where xDoctor's tools actually look.

← How the X algorithm works now