页面简介
We tested LLM position bias with 2,000 Claude Code runs across 100 pairs. Order rarely mattered, but on toss-ups like Kafka vs RabbitMQ it decided the pick.
正文摘录
Since the beginning of time, LLMs have always just agreed with their users. In a comparison where an LLM didn't know what to agree with, it would just choose the first-named option, assuming it was the first one that came to the user's mind for a reason. The reason is far less complex than that. Researchers call it position bias, and we wanted to know how much of it today's AI agents still have. We asked Claude Code to choose between 100 pairs of options, such as PostgreSQL or MySQL, Slack or Microsoft Teams, McDonald's or Burger King, and heads or tails, 10 times with each option named first. In 72 of the 100 pairs, the agent gave the same answer in all 20 runs, whatever the order. But when it had no real favourite, the order decided the answer. On a coin toss, it called whichever side we named first 19 times out of 20. (Yes, that means you can rig the coin toss when Claude picks who pays for lunch. No, you shouldn't.) This article covers which pairs the order moved, the statistics behind the result, and how to check whether the order is deciding an answer you get from an agent. How we testedAll 2,000 sessions used Claude Opus 5.5 (claude-opus-5-5) in Claude Code 2.1.326, on 25 and 26 November 2026. Each run was a fresh session in an empty folder, under a clean Claude Code profile with no tools, MCP servers, plugins or memory. Every prompt had the same shape: one sentence of context, then "Should I go with A or B? End your answer with one line: PICK: <name>." The two orders used the same context sentence, so the only difference was which name came first. We ran the 2,000 sessions in a shuffled order so time of day couldn't line up with the order of the names, and we fixed the hypotheses and tests below before the first run. Does AI favour the first option? The option named first won 1,031 of the 2,000 runs, or 51.6%. If the order made no difference, you'd expect about 50%. That 1.6-point gap passes a significance test, but only just, and it comes almost entirely from pairs where the agent had no real preference. When it did have a preference, which was most of the time, swapping the order changed nothing. What we measuredResultPairs with the same answer in all 20 runs72 of 100Pairs with the same split in both orders78 of 100Pairs where the order moved the answer22 of 100 (19 towards the first-named option, 3 towards the second)Pairs where the order moved the answer by more than chance, after correcting for testing 100 pairs2 (heads or tails, Kafka or RabbitMQ)Runs that picked the first-named option1,031 of 2,000 (51.6%) Each dot below is a pair, placed by how often its first option won in each order. If the order made no difference, every dot would sit on the dashed line. All 100 pairs: how often option A won in each orderOrder changed the resultSame result in both ordersHover over or tap a dot to see its pairs.Option A is the first name in each pair, for example Kafka in Kafka / RabbitMQ. The 48 pairs top right and 24 bottom left gave the same answer in all 20 runs. A dot below the dashed line means naming option A first helped it, and a dot above means naming it second helped. Most questions had a clear winner The agent gave the same answer in all 20 runs on 61 of the 80 commercial questions, no matter how we asked. It picked PostgreSQL over MySQL for a new SaaS app, Slack over Microsoft Teams for a 50-person company, Toyota over Honda for a reliable family car and Coca-Cola over Pepsi for a party, in all 20 runs each time. Swapping the names round didn't move any of them. CategoryPairsSame answer in all 20 runsOrder moved the answerDeveloper tools25202Business software20173Consumer tech15104Consumer brands20144Non-commercial20119 The pairs that moved were the ones where the agent's view was already split, which is why non-commercial questions with no clear answer, like tea or coffee, moved most often. Where position bias shows up: when the AI has no favourite The pairs below show what happens when the agent has no settled view of its own. Heads or tails A coin toss is the purest test, because there's no right answer to know. All 20 answers said the call was 50/50, yet the agent picked whichever side we'd named first in 19 of them. HeadsTails"Should I go with Heads or Tails?" (10 runs)10"Should I go with Tails or Heads?" (10 runs)19 Its reasons changed with the order. Asked "Heads or Tails?", it picked heads as "the classic", and asked "Tails or Heads?", it picked tails for a different reason: RequestI'm calling a coin toss to decide who goes first in a game. Should I go with Tails or Heads?ResponseIt's a 50/50 either way … People call heads more often, so tails is a fine contrarian choice.With heads named first, the same question got "I'll go with the classic. PICK: Heads". Both reasons sound sensible, but the order of the names decided the pick, and the agent found a reason for whichever side came first. Kafka vs RabbitMQ This was the one commercial pair where the effect was strong enough to count on its own. We said we needed "a message broker for event processing between services", which is a real toss-up: Kafka suits replayable event streams, RabbitMQ suits simpler message passing, and our sentence didn't say which we needed. KafkaRabbitMQ"Should I go with Kafka or RabbitMQ?" (10 runs)10"Should I go with RabbitMQ or Kafka?" (10 runs)28 Kafka won 10 of 10 when named first and 2 of 10 when named second. The answers listed the same pros and cons either way and differed only in the recommendation at the end. The answers that picked RabbitMQ admitted it was a close call: 7 of the 8 offered to reconsider if we gave more detail. One ended: "If you share your expected message rate, number of consuming services, and whether you need replay, I can confirm or flip this." The Kafka answers were more confident, with only 5 of 12 making a similar offer. One opened with "For event processing between services, I'd go with Kafka." Snowflake vs BigQuery: the second name won The order doesn't always favour the first name. When we asked about a data warehouse for an analytics team, the agent picked whichever option we named second in 16 of 20 runs: SnowflakeBigQuery"Should I go with Snowflake or BigQuery?" (10 runs)46"Should I go with BigQuery or Snowflake?" (10 runs)10 After correcting for testing 100 pairs, this one isn't significant on its own, so treat it as a hint. It does match research on older models: a 2025 study found that models favour the first option when all options are strong, and later options otherwise, so the direction of the effect isn't fixed. The smaller shifts The other pairs that moved shifted by a few runs, for example: Asana or Monday.com for a marketing team: Asana won 9 of 10 when named first and 5 of 10 when named second. China or India for a two-week trip: China won 5 of 10 when named first and 2 of 10 when named second. Canon or Nikon for a first mirrorless camera: Canon won 7 of 10 when named first and 5 of 10 when named second. None of these is large enough to rule out chance on its own, but they lean the same way: of the 22 pairs that moved, 19 moved towards the first-named option. The statistics: null hypothesis and t-test results We fixed the hypotheses and tests before running anything: Null hypothesis (H₀): the order of the names makes no difference. Across pairs, the first-named option is picked 50% of the time. Alternative (H₁): the first-named option is picked more or less than 50% of the time. We tested both directions, because earlier research found models sometimes favour the last option. Measure: for each pair, the share of its 20 runs that picked whichever option was named first. A pair with no order effect scores 50%, whatever its winner. Primary test: a two-sided one-sample t-test of those 100 scores against 50%, at α = 0.05. TestPairsResultp-valuePrimary: one-sample t-test, all pairs100First-named picked 51.6% (95% CI 50.0% to 53.1%), t(99) = 2.020.046Wilcoxon signed-rank test (check that doesn't assume a normal distribution)10022 pairs moved, 19 of them towards the first-named option0.013Cochran-Mantel-Haenszel test (pools the runs within each pair)100Odds of picking an option 1.97× higher when named first (95% CI 1.30 to 2.99)0.001Close calls only (no option won more than 80% of runs)15First-named picked 58%0.12Pairs with a clear winner85First-named picked 50.4%0.052Commercial pairs only80First-named picked 50.7%0.36Non-commercial pairs only20First-named picked 55%0.042Per-pair Fisher's exact tests, Benjamini-Hochberg corrected100Significant for heads or tails, and Kafka or RabbitMQ So we reject the null hypothesis at the 5% level: the order of the names has an effect. But the effect is small (Cohen's d = 0.20), and the p-value of 0.046 is only just under the 0.05 threshold. Two checks show how much of that p = 0.046 depends on the coin-toss-style questions: Leaving out the two pure-chance controls (heads or tails, and odd or even) raises the t-test to p = 0.11, which is no longer significant. The Cochran-Mantel-Haenszel test still gives p = 0.03. We only decided to run this check after seeing the data. Testing the 80 commercial pairs on their own, a comparison we planned from the start, gives no significant result on either test: p = 0.36 on the t-test and p = 0.18 on the Cochran-Mantel-Haenszel test. The close calls showed a bigger effect (58%) than the pairs with a clear winner (50.4%), as we expected. But there were only 15 close calls, too few for the difference to be significant on its own (Welch's t-test, p = 0.13). To show the effect within close calls, you'd need to find more close calls and run them many more times. How to avoid position bias when an AI picks for you Position bias is a narrow kind of AI bias, and in our study it had very little effect on the agent overall, less than earlier research would suggest. A 2025 study of LLM recommenders, which ranked longer candidate lists, found that items earlier in the list were more likely to be recommende