<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Saksham Arora on Medium]]></title>
        <description><![CDATA[Stories by Saksham Arora on Medium]]></description>
        <link>https://medium.com/@nerfsaksham?source=rss-9f8259d762ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*V0L54FcbM0c2EInBqabfWA.png</url>
            <title>Stories by Saksham Arora on Medium</title>
            <link>https://medium.com/@nerfsaksham?source=rss-9f8259d762ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:06:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nerfsaksham/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I Read X’s Algorithm: A Mutual’s Reply = 30 Likes · Saksham Arora]]></title>
            <link>https://nerfsaksham.medium.com/i-read-xs-algorithm-a-mutual-s-reply-30-likes-saksham-arora-203aff705701?source=rss-9f8259d762ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/203aff705701</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Saksham Arora]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 00:00:56 GMT</pubDate>
            <atom:updated>2026-11-04T16:36:45.206Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EJYJEb0HnaK3jLc5.png" /></figure><p>xAI open-sourced the code behind X’s For You feed. Most of what I saw online about it came from the README or from people quoting each other, so I cloned the repo and read the code itself: the Rust that builds your feed, the JAX that trains the model, and the config file X syncs from production.</p><p>This is what I found, read at commit b220448 from 3 November 2026. Every number below is from the code, with the file it lives in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3GlP_c5lW0Cs0dII.png" /></figure><p><em>The repo. 2,352 files of Rust, JAX and Scala, with a commit almost every weekday.</em></p><p>Before the numbers, here’s the whole path a feed takes. Every time you open For You, this runs from left to right:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K5_hXH8twJMTZFm1.png" /></figure><p><em>One feed request, start to finish. Most of this post is about the green and amber boxes.</em></p><p>Every post you could see gets one score:</p><pre>score = sum of (weight × the chance you&#39;ll take that action)</pre><p>The model predicts the chance you’ll like, reply, repost, share, mute, report and about 20 other actions. Each prediction is multiplied by a weight, and the results are added up. The weights live in home-mixer/params/param.rs, and X runs a cron job that copies the production values into that file. The last sync before I read it was 2 November.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ssYllj8wvxBkYjdm.png" /></figure><p><em>The actual lines, from the file X syncs from production.</em></p><p>One thing to get right before reading too much into this table. The weights multiply your <em>predicted chance</em> of doing something, not counts. Reports are more than 1,000 times rarer than likes, so a report needs a huge weight just to move the ranking at all. “One report cancels 354 likes” is the wrong reading, and X even added a code comment saying so.</p><p>The right reading: X values conversation and sharing far more than approval. A reply is worth about 7.6 likes. A copied link is worth about 30.</p><p>There is one extra parameter, bidirectional_follow_reply_weight_boost = 15. If the post is an original post (not a reply or a repost) and the author follows you back, the reply weight goes from 5 to 20.</p><p>So <strong>one reply from a mutual is worth about 30 likes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jo7R6DXXS8Zf1jlJ.png" /></figure><p><em>The whole eligibility rule is one line: original post, and you follow each other.</em></p><p>X documented the rollout in docs/BIDIRECTIONAL_BOOST_CHANGE.md. They A/B tested boosts of 5, 10, 15 and 20 starting 10 July 2026, shipped 20 on 13 July, then cut it to 15 on 24 July after people complained they were missing World Cup posts from accounts they didn&#39;t follow.</p><p>This is easy to miss. In xai-value-model/scoring.rs, a post with a positive total gets a small constant added. A post with a negative total gets squashed into a tiny range below that constant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CHvFQKQxVAj1Kta4.png" /></figure><p><em>Positive totals get </em><em>+ 0.001. Negative totals get squeezed in below 0.001.</em></p><p>So <strong>every post with a negative total ranks below every post with a positive total</strong>, no matter how close to zero it is. If the model thinks a viewer is likely to mute you or hit “not interested”, your post is effectively gone from their feed.</p><p>These adjustments don’t run where the README says. Home-mixer hard-codes them off, and the separate vm-ranker service applies them:</p><ul><li><strong>Same-author decay.</strong> Your k-th post in one feed load is multiplied by 0.75 × 0.5^k + 0.25. Your 1st post keeps 100%, the 2nd 62.5%, the 3rd 44%, and it never drops below 25%.</li><li><strong>Out-of-network discount.</strong> Posts from accounts the viewer doesn’t follow get ×0.75. So do replies and reposts from accounts they do follow.</li><li><strong>Diversity rerank.</strong> Out of the top 150, a determinantal point process (θ = 0.65) trades a little score for posts that look less alike, using cosine similarity of post embeddings. Ten near-identical takes on the same news story won’t all make it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9-EevhF9oC3WgSQc.png" /></figure><p><em>Posting a burst doesn’t multiply your reach. Each extra post in one feed keeps less of its score.</em></p><p>There is no time decay in the score. Freshness comes from a hard 48-hour cutoff and from post age being one of the model’s inputs.</p><p>home-mixer/scorers/author_cold_start.rs is a real bandit. On each feed request, at most one post gets lifted to slot 16 if all of these are true:</p><ul><li>it’s an original post, not a reply or a repost</li><li>the author has <strong>50,000 followers or fewer</strong></li><li>the post is <strong>under 2 hours old</strong></li><li>it has <strong>fewer than 200 home-feed views</strong></li></ul><p>To pick which one, X uses Thompson sampling. For each candidate it draws a like rate from Beta(0.75 + likes, 49.25 + views − likes), which starts at a 1.5% prior. It keeps the top 2 draws and takes whichever the model scores higher.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6Pu-kIHVOHQnlMuA.png" /></figure><p><em>The bandit, in 13 lines.</em></p><p>Here’s what that looks like for two example posts with the same 150 views:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IFraaDgMsPh1f6a7.png" /></figure><p><em>The post with 9 likes almost always draws a higher number, so it almost always wins the slot. The post with no data yet still has a long tail, which is how new posts get a chance.</em></p><p>In plain words: <strong>your likes per view in the first 2 hours decide whether X tests you on new people.</strong></p><p>If you work on recommender systems, this part is worth reading on its own. It’s the most complete production recommender I’ve seen released.</p><ul><li><strong>Ranking:</strong> a transformer with 8 layers, width 2560, and 20 query heads sharing 4 key/value heads. It reads your last 1,022 actions plus 64 candidate posts.</li><li><strong>Candidate isolation:</strong> candidate posts can attend to your history but not to each other. A post’s score doesn’t depend on what else is in the batch, so it can be cached.</li><li><strong>Hash embeddings:</strong> users, posts and authors are hashed into tables of 100M, 100M and 30M rows, two hashes each, so there’s no vocabulary to maintain and a brand-new post works instantly.</li><li><strong>Semantic IDs:</strong> each post’s multimodal embedding is quantized into 6 levels of 256 codes. Posts on the same topic share code prefixes, which helps the model generalise to posts it has never seen.</li><li><strong>About you:</strong> country, language, location, inferred gender, age bracket, and a 10-million-row table of IP address hashes. An installed-apps feature exists but is switched off in the ranker.</li><li><strong>Training:</strong> 1e11 examples, the Muon optimizer for dense weights, row-wise AdaGrad for the embedding tables.</li><li><strong>8 October change:</strong> time-spent prediction moved from a Tweedie + MAE loss to CREAD, which classifies dwell time against 30 log-spaced thresholds from 2 to 120 seconds and then restores a number. That’s what the changelog means by “predicts time spent much better”.</li></ul><p>Retrieval, the step that finds posts from people you don’t follow, is a two-tower model. A transformer encodes your history into one vector, and the top matches come from an index of about 10 million posts.</p><p>After ranking, visibility-filtering checks every post. Some rules drop a post for everyone: suspended authors, spam labels, legal takedowns, and &quot;Freedom of Speech, Not Reach&quot; labels for hateful conduct, violent speech, abuse and civic integrity.</p><p>A second set only applies when the post would reach someone who doesn’t follow the author. These include account labels like SPAM_HIGH_RECALL, IMPERSONATION_HIGH_PRECISION, ABUSIVE_HIGH_RECALL and <strong>DO_NOT_AMPLIFY</strong>. Followers still see the post. Strangers never do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m8fRexgmbxvCn7Ri.png" /></figure><p><em>The list of account labels that block recommendations to non-followers. </em><em>DO_NOT_AMPLIFY is the last one.</em></p><p>That’s the “not banned, just not recommended” mechanism, written down in visibility-filtering/rules/levels.rs. The labels come from LLM classifiers running on Grok 4.1 Fast (the prompts aren&#39;t published), image and video models, and offline account-scoring jobs. X&#39;s <a href="https://x.com/i/jf/under_the_hood">Under the Hood</a> page shows which labels are on your own account.</p><ul><li><strong>Premium gets no boost in ranking.</strong> Subscription level only shows up in ads logging and reply controls.</li><li><strong>Strangers mass-reporting you does little.</strong> Only actions on posts X actually served in the feed count, and predictions are personalised, so reports mostly affect people who behave like the reporters.</li><li><strong>Links aren’t penalised by a weight.</strong> Opening a link is +0.2. Link posts lose because people reply to them less.</li><li>The README links visibility-filtering/rules/registry.rs, but that file doesn&#39;t exist. The rules are in tweet_rules.rs, author_rules.rs and levels.rs.</li><li>The README says the ranking scorer applies the author-diversity and out-of-network adjustments. In the code they’re switched off there and applied in vm-ranker.</li><li>FairShareRankingFilter is enabled in production but missing from the README&#39;s filter list. It trims candidates to 2,800, split proportionally across sources.</li><li>The Brazil2026ElectionFilter was removed on 26 October, but a visibility rule that drops election-labelled posts for viewers in Brazil is still in the code.</li></ul><ol><li><strong>Write things people reply to or send to a friend.</strong> A reply is 5, a copied link 20, a like 0.66.</li><li><strong>Build mutuals in your niche.</strong> Their replies count four times as much.</li><li><strong>Post when your audience is online.</strong> The first 2 hours decide the small-account slot.</li><li><strong>Post once, not three times in a row.</strong> The 3rd post keeps 44%.</li><li><strong>Don’t bait strangers.</strong> A predicted mute or “not interested” puts you below every positive post.</li><li><strong>Check Under the Hood</strong> before blaming the algorithm.</li></ol><p>None of this is a cheat code. The weights are fixed, but the predictions come from a model trained on what people really did. The only way to raise “chance this person replies” is to write something they want to reply to.</p><p>The repo is at <a href="https://github.com/xai-org/x-algorithm">github.com/xai-org/x-algorithm</a>. The small model configs train on one NVIDIA GPU if you want to run Phoenix yourself.</p><p><em>Originally published at </em><a href="https://saksham.digital/blog/29_i_read_the_x_algorithm"><em>https://saksham.digital</em></a><em> on November 4, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=203aff705701" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything Claude Codex: 11 Lessons From 11 Months in Claude Code]]></title>
            <link>https://nerfsaksham.medium.com/everything-claude-codex-11-lessons-from-11-months-in-claude-code-3ef11f665cba?source=rss-9f8259d762ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ef11f665cba</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Saksham Arora]]></dc:creator>
            <pubDate>Thu, 29 Oct 2026 00:00:34 GMT</pubDate>
            <atom:updated>2026-11-04T13:25:11.325Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fO9649TeoLh5iwu-.jpg" /></figure><p>11 months ago I started using Claude Code. Every session began the same way: me explaining who I am, what I’m building, what I already tried, and what’s due this week.</p><p>I’m a student doing two degrees at the same time, a B.Tech in CSE and the IIT Madras BS in Data Science. My life is a pile of parallel deadlines. I needed an assistant that remembered. What I had was a brilliant stranger I had to brief from scratch every morning.</p><p>So I started fixing it, one annoyance at a time. 11 months and 51 public repos later, that pile of fixes is the system I run my whole week on: two AI agents that share one memory, notes that answer me from my phone with my laptop shut, search over everything I’ve ever written, and a setup that tells me when it’s broken.</p><p>Today it’s open source. ECX: everything claude codex.</p><p>Here are the 11 lessons that built it. Each one became a piece of the repo.</p><p>The biggest jump in quality I ever got didn’t come from a better model. It came from one file.</p><p>hot.md holds what&#39;s true right now: live deadlines, what I&#39;m building, what I&#39;ve dropped and why. A hook loads it, plus summaries of my last few sessions, before my first message. After every /compact it gets refreshed.</p><p>Claude stopped asking what I was working on. It started telling me what was due.</p><p><strong>In ECX:</strong> templates/hot.md, the session_context hook, memory/update_hot.py.</p><p>I used to paste the same paragraph every time I wanted internship help: read my tracker, check deadlines, check eligibility, never show me anything expired.</p><p>Now I type /opps. Same for the morning brief (/boot), networking (/outreach), shipping (/ship), and turning any video into notes (/video-notes). Skills are where your habits turn into infrastructure.</p><p><strong>In ECX:</strong> 17 skills. They read who you are from hot.md, so none of them are about me.</p><h3>3. Rules in CLAUDE.md are suggestions. Hooks are laws.</h3><p>I told Claude, in writing, never to put em dashes in anything I publish. They’re the fastest tell that a post was written by AI. It agreed every time, and kept using them.</p><p>A 16-line hook that flags them the moment a draft is saved did what every reminder couldn’t. If something has to happen every single time, it belongs in a hook, not in a sentence the model may or may not weigh.</p><p><strong>In ECX:</strong> 19 hooks, including the AI-tell guard.</p><p>I had a “dangerous command” guard. Its job was to stop things like rm -rf ~.</p><p>It read an environment variable that Claude Code never sets. So for months it checked an empty string and approved everything. I found out while packaging this repo, when I finally sent it the exact JSON Claude Code sends.</p><p>If you copied a guard from a blog post, test yours today.</p><p><strong>In ECX:</strong> guard_dangerous.py blocks rm -rf ~ and disk formats, and asks before force-pushes, reset --hard and DROP TABLE. The tests send it the same payload Claude Code does.</p><p>My nightly search index failed 120 nights in a row. No error, no alert. The search tools kept answering, just from notes that were four months old.</p><p>Things that break loudly get fixed. Things that break quietly rot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pqTbry7G7KQJcIOo.png" /></figure><p><strong>In ECX:</strong> doctor. 16+ checks across hooks, indexes, scheduled jobs and sync, each with the exact command that fixes it.</p><p>When an MCP server’s backend is down, the agent doesn’t know. It calls the tool, gets nothing useful back, and reasons confidently on top of an empty answer.</p><p>My graph search did exactly this because Ollama wasn’t running, and nothing told me. Now a hook checks the dependency before the call. After two failures in ten minutes it blocks the tool and says why.</p><p>Claude would tell me a task was done. Then I’d look: nothing committed, nothing pushed, nothing live.</p><p>My rule now: no “done” without proof. A test output, a live URL, or a commit hash. /ship commits, pushes and reports the proof in one pass.</p><p><strong>In ECX:</strong> /ship, plus a hook that runs your tests before Claude Code or Codex can say done, and sends the agent back with the failing output if they fail.</p><p>The best voice AI I’ve used is in the ChatGPT app, and Codex lives there. But Codex knew nothing about me.</p><p>Step one was AGENTS.md, a file that tells Codex to read exactly what Claude reads. Step two was agent-sync: before every message, a hook hands each agent the newest lines of the other&#39;s chats, voice transcripts included. About 0.05 seconds, one Python file, no server.</p><p>The test: I told Codex by voice, “let our codeword be PVC.” Switched to Claude and typed “what’s my code word, don’t read any files.”</p><p>It said PVC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dhDTlSq872Ec4QBy.png" /></figure><p><strong>In ECX:</strong> agent-sync/, plus mail so the two agents can message each other directly.</p><p>Before this I built JARVIS: a Discord bot running Claude, screen memory and a local model, all on my Mac. It was great until I closed the lid.</p><p>The fix needed no server at all. After every reply, my notes and a copy of my memory sync to a private GitHub repo. On my phone, the Claude app and the ChatGPT app work on that repo in the cloud.</p><p>I ask “what’s due this week?” and get my real deadlines. I say “I met Adi, he works at X” and it lands as one note in my inbox, filed the next time I open my Mac.</p><p><strong>In ECX:</strong> phone-vault/, including a GitHub Action that auto-merges inbox-only changes and holds everything else for review.</p><p>Grep finds words. I needed to find ideas. So the vault is searchable three ways:</p><ul><li><strong>By meaning:</strong> “notes about latency” finds them even if the word never appears.</li><li><strong>By relationship:</strong> “how does X connect to Y” walks a knowledge graph.</li><li><strong>By image:</strong> “the slide with the gradient descent diagram” finds the slide and the note it lives in.</li></ul><p>A router picks the right one per question, and everything re-indexes every night.</p><p><strong>In ECX:</strong> vault-search/, three MCP servers plus image search.</p><p>Once the phone worked, I wanted it to know everything my Mac knew. So I almost synced my full Claude chat history to GitHub.</p><p>Then I checked what was in it: real API keys, sitting in tool output. Git history is forever, even in a private repo.</p><p>The phone gets session summaries instead. It turned out to be enough.</p><p><strong>In ECX:</strong> phone sync pushes summaries and memory, never transcripts.</p><ol><li>Write your hot.md. Ten lines: who you are, what you&#39;re building, what&#39;s due.</li><li>Turn your most repeated prompt into a skill.</li><li>Test your guard with the real payload.</li></ol><p>Or skip to the end:</p><pre>git clone https://github.com/saksham10arora-dotcom/everything-claude-codex ~/ecx cd ~/ecx &amp;&amp; ./install.sh</pre><p>Two questions, 30 seconds. It never overwrites your files and backs up every settings file it touches. Everything except agent-sync works with Claude Code alone.</p><p>11 months ago Claude Code asked me what I was working on. Now it tells me.</p><p>If this saves you even one of those months, a star helps other people find it.</p><p><a href="https://github.com/saksham10arora-dotcom/everything-claude-codex">github.com/saksham10arora-dotcom/everything-claude-codex</a></p><p>The longer story of the vault, the phone bridge and everything that broke while building them is in <a href="https://saksham.digital/blog/25_my_second_brain_has_two_ais">My Second Brain Has Two AIs and Works With My Laptop Shut</a>.</p><p><em>Originally published at </em><a href="http://saksham.digital/blog/28_11_months_in_claude_code_11_lessons"><em>https://saksham.digital</em></a><em> on October 29, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ef11f665cba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Second Brain Has Two AIs and Works With My Laptop Shut]]></title>
            <link>https://nerfsaksham.medium.com/my-second-brain-has-two-ais-and-works-with-my-laptop-shut-6706a524d026?source=rss-9f8259d762ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/6706a524d026</guid>
            <category><![CDATA[second-brain]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Saksham Arora]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 00:00:49 GMT</pubDate>
            <atom:updated>2026-11-04T13:24:10.999Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ya9RNL-gBhnCuKpV.jpg" /></figure><p>Right now, with my MacBook closed in my bag, I can open my phone and ask “what’s due this week?” and get an answer from my own notes. I can say “I met Adi, he’s at X, we talked about Y” and it lands in my vault.</p><p>Claude and Codex share one memory. I tell one of them something, and the other already knows.</p><p>None of this is one product. It’s a stack of small pieces I added over five months, mostly because something annoyed me. Here’s all of it, including the parts that broke.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ydQBuYwqzWgHSp18.png" /></figure><p><em>The whole system on one screen. Everything below is one of these boxes.</em></p><p>It’s an Obsidian vault. Trackers, deadlines, lecture notes, people I meet, half-baked ideas. All plain markdown, all in git.</p><p>One rule runs the whole thing: <strong>capture first, organize later.</strong> Anything new goes into inbox/. I never decide where something belongs while I&#39;m capturing it. An agent files it later.</p><p>Everything else has a home:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ehO5EZHnfSGT8HU8.png" /></figure><p><em>Real counts. The inbox stays near empty because an agent files it, and the archive is where raw captures go after </em><em>/wiki compiles them.</em></p><ul><li>daily/ for brain dumps, studies/ for courses and trackers, projects/ for builds, personal/ for people, internships and applications, content/ for posts, research/ for deep dives</li><li>wiki/: when the inbox fills up, /wiki compiles the raw captures into linked articles (Karpathy&#39;s LLM-wiki idea) and moves the originals to archive/</li><li>Lecture notes write themselves: <a href="https://saksham.digital/margin">Margin</a>, my lecture-notes extension, drops a finished note with the slides into the vault when a lecture ends, and /watch does the same for any YouTube video</li></ul><p>Around that sit a few “machines”, each one a tracker file plus a skill that reads it: a daily brief, internships and applications, networking, content, open source, and my resume. I say /opps and Claude reads the opportunities tracker before it says anything.</p><p>Inside Obsidian, 15 plugins do the rest. Dataview and Tasks turn notes into live tables and to-do lists, Templater stamps out new notes, Spaced Repetition turns notes into flashcards, Smart Connections finds related notes, and a Claude Code bridge lets agents read and write the open vault directly.</p><p>Claude Code starts every session already knowing my situation, because three things get loaded before I type anything:</p><ul><li>hot.md: what&#39;s true right now. Live deadlines, what I&#39;m working on, what I&#39;ve killed and why.</li><li>60+ memory files: how I like to work, corrections I’ve made (“don’t suggest X again”), the state of every project.</li><li>Weekly summaries of every past session, written automatically when a session ends.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R9mqmN_RRBjoXVJB.png" /></figure><p><em>Hooks fire at four fixed points, so nothing depends on me remembering.</em></p><p>Hooks do the loading, so I never paste context. And 34 skills turn repeat jobs into one word: /daily for the morning brief, /opps for internships, /content for posts like this one.</p><p>Reading every note on every question doesn’t scale, so the vault is indexed three ways:</p><ul><li><strong>ChromaDB</strong>: semantic search (“notes about latency”)</li><li><strong>LightRAG</strong>: relationship search (“what connects my HFT engine to my IMC Prosperity strategy”)</li><li><strong>CLIP</strong>: images, so screenshots and lecture slides are searchable too</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xVVYTlKrxBEGTypZ.png" /></figure><p><em>One question in, the right index out.</em></p><p>A small router server picks the right one per question. All of them run as MCP servers, so any agent can use them, and they re-index every night: about 11,000 chunks of my own notes. On top of that, a knowledge graph of the whole vault answers structural questions like “how does X relate to Y” without grepping 2,000 files.</p><p>The voice mode in the ChatGPT app is the best voice AI I’ve used. Codex lives inside it. But Codex knew nothing about me.</p><p><strong>Step one: give Codex the same memory.</strong> One file, AGENTS.md, tells Codex to read exactly what Claude reads at the start of every chat. I tested it by asking about a fact that only exists in Claude&#39;s memory files. It got it right after reading all 71 of them.</p><p><strong>Step two: make them know what I said to each other.</strong> That’s agent-sync. Before every message I send, a hook on each side reads the newest lines of the <em>other</em> agent’s chat logs and hands them over. Codex voice transcripts included. It takes about 0.05 seconds, one local Python file, no server.</p><p>The test: I told Codex, by voice, “let our codeword be PVC.” Switched to Claude and typed “what’s my code word, don’t read any files.” It said PVC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bWfnllNP9mFsYKMm.png" /></figure><p>For older history, both agents use <a href="https://github.com/Kuberwastaken">Kuber</a>’s <a href="https://github.com/Kuberwastaken/reference">reference</a>, which lets each one search the other’s past sessions. It skipped Codex voice transcripts, so I sent him a PR for that.</p><p>Before this, I built JARVIS: a Discord bot running Claude, screen memory, and a local model, all on my Mac. It worked great until I closed the lid. An assistant that needs your laptop on 24/7 isn’t an assistant.</p><p>The fix needed no server. <strong>The private GitHub repo is the bridge.</strong></p><ul><li>After every reply on my Mac, a sync script pushes my notes plus a copy of the memory files to the repo.</li><li>On my phone, Codex in the ChatGPT app and Claude Code on the web both work on that repo in the cloud. They read the same memory, so they know me with the Mac off.</li><li>When I tell the phone something new, the agent writes exactly one note into inbox/. A GitHub Action merges changes that only touch inbox/ automatically. Anything else waits for me.</li><li>Next time I open my Mac, the note syncs down and Claude files it in the right place.</li></ul><p>Then I tried it for real. From my phone, no Mac needed, I asked Claude “what’s due this week?” and it listed my actual deadlines from the vault. Then I told it my first IITM exam is on November 15. The note was on GitHub straight away and on my Mac three minutes later, already waiting to be filed. (Before that, I’d tested the guard rail: a fake change to a file outside inbox/ was correctly left for me to review.)</p><p>For anyone who wants the full list:</p><ul><li><strong>MCP servers (Claude):</strong> vault search (ChromaDB), vault graph (LightRAG), the router, the live Obsidian bridge (while Obsidian is open), reference, screenpipe for screen memory, GitHub, Puppeteer for the browser, Hashnode for the blog, and a Discord channel</li><li><strong>MCP servers (Codex):</strong> the same three vault servers, plus reference and screenpipe</li><li><strong>Connectors:</strong> Gmail, Google Calendar, Google Drive, and Higgsfield for images</li><li><strong>Hooks (11):</strong> restore context and sort the inbox at session start; block dangerous shell commands and nudge toward the knowledge graph before searching; auto-approve read-only actions with a small model; flag em dashes in anything I’ll publish; archive the session and sync to GitHub after every reply; refresh hot.md after the context gets compacted; and agent-sync before every message</li><li><strong>Scheduled jobs (6):</strong> re-index ChromaDB, LightRAG, a Gemini-embedding copy and the CLIP image index every evening; sync my competitive programming stats overnight; and a morning check that flags trackers I’ve stopped updating</li><li><strong>The voice model starts blind.</strong> Codex voice is two models: a fast voice model you talk to, and the agent behind it. The app starts the voice model with includeStartupContext: false. It only gets my context when it hands a task to the agent. So by voice, I ask in tasks: &quot;check my notes and tell me...&quot;</li><li><strong>macOS quietly blocks background jobs from your Desktop folder.</strong> It killed my every-10-minutes sync timer on day one. Worse: while writing this, I found my main search index job had failed with the same error <strong>120 nights in a row</strong>. The search I relied on hadn’t updated since May 13, and never told me. The fix was one line: point the job at the Python my other nightly jobs already use. It’s fresh again.</li><li><strong>JARVIS</strong>, see above. Lesson: decide where a thing lives before deciding what it does.</li></ul><p>The rest lives in my private vault repo. If you want a specific piece, ask and I’ll pull it out.</p><p><em>Originally published at </em><a href="http://saksham.digital/blog/25_my_second_brain_has_two_ais"><em>https://saksham.digital</em></a><em> on October 10, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6706a524d026" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Average Latency Lie: What 100 LLM API Calls Taught Me About Benchmarking]]></title>
            <link>https://nerfsaksham.medium.com/the-average-latency-lie-what-100-llm-api-calls-taught-me-about-benchmarking-221fe34d72e1?source=rss-9f8259d762ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/221fe34d72e1</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[benchmark]]></category>
            <dc:creator><![CDATA[Saksham Arora]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 00:00:02 GMT</pubDate>
            <atom:updated>2026-11-04T13:07:58.511Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>I benchmarked an LLM API 100 times. The mean said 1.7 seconds. The median said 2.2 seconds. If that ordering looks impossible to you, good. That instinct is the whole point of this post.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R6sxMP8lmiwDKrNN.png" /></figure><p><em>The whole post in one picture. The mean describes a request that never happened.</em></p><h3>The number everyone reports is the wrong one</h3><p>Search for any LLM latency comparison and you will find the same chart: average response time per provider. One bar for OpenAI, one for Anthropic, one for Groq. Clean, comparable, useless.</p><p>Here is why. Latency is not a number, it is a distribution. And LLM API latency distributions are ugly: long tails, queueing cliffs, cold starts, rate limit walls. The mean compresses all of that structure into one value that frequently describes no request that actually happened.</p><p>In trading systems this lesson is beaten into you early. Nobody at any serious shop reports mean latency. You report p50, p95, p99, p99.9. The p99 is what your worst user feels, and in production the worst user is the one who files the ticket.</p><p>LLM APIs deserve the same treatment. So I built a tool that does it: <a href="https://github.com/saksham10arora-dotcom/llm-bench">llm-bench</a>.</p><h3>The run that proved the point</h3><p>The first real benchmark I ran with the finished tool was 100 requests to Groq’s free tier, llama-3.3–70b-versatile, sequential, after warmup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xDwFHJDNmi98PJfT.png" /></figure><p><em>The real output. The mean (red) is half a second below the median (blue).</em></p><p>Look at the TTFT row. The mean is 1.71s. The median is 2.20s. The mean is below the median by half a second.</p><p>For a right-skewed latency distribution (the normal case), the mean sits above the median because the tail drags it up. Here the opposite happened, which means the distribution is not skewed, it is bimodal:</p><ul><li>The first ~30 requests returned in roughly 200ms. Fast path, no queueing.</li><li>Then the free tier’s rate limiter woke up. Every request after that waited about 2.2 seconds.</li></ul><p>Two completely different latency regimes inside one run. The mean averaged them into 1.7s, a number that describes neither regime. No single request experienced 1.7s. The median, sitting in the throttled majority, told the truth about what most requests actually felt.</p><p>A mean-only benchmark would have printed “1.7s” and moved on. You would have shipped a latency budget based on a number that does not exist.</p><h3>What llm-bench measures, and why</h3><p>Every measurement decision in the tool is documented in the README, because a benchmark you cannot interrogate is just a vibe with a table. First, what one request actually looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3raypco7CMxhoY0V.png" /></figure><p><em>Every metric below is a different slice of this one timeline.</em></p><p>The short version:</p><p><strong>TTFT, separately from total latency.</strong> Time to first token is what a user perceives as “the app is responding.” It deliberately includes connection setup, queueing, and prefill, because the user waits through all of it. Total latency ends at the last content chunk, not at trailing usage frames or connection teardown.</p><p><strong>Real percentiles, nearest-rank.</strong> No interpolation, no smoothing. With n=100, p99 is your second-worst request, an actual observation, not an invented value between two observations. The tool warns you below n=100 because p99 of 5 samples is just the max wearing a costume.</p><p><strong>Inter-token latency from pooled raw gaps.</strong> Every gap between consecutive chunks is timestamped and pooled across all requests, then percentiles are computed on the raw gaps. The tempting shortcut is to average gaps per request first. That shortcut destroys exactly the signal you want: one 500ms stall inside an otherwise smooth stream disappears into that request’s average. Pooling keeps it visible at p99.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p9qULafusLNe0AOU.png" /></figure><p><em>This is the exact case from the test suite. The 500 ms stalls are real, but averaging per request reports about 12 ms.</em></p><p><strong>Throughput as decode rate.</strong> Tokens per second is computed as (completion_tokens — 1) / (total — TTFT). Including TTFT in the denominator blends queueing and prefill into a number that claims to be generation speed. Groq’s 536 tok/s above is decode rate, the speed at which tokens actually streamed once they started.</p><p><strong>Errors never touch the percentiles.</strong> A timed-out request has no valid latency. It gets counted and reported (errors: 0/100) but never averaged in, because a 30s timeout “latency” would poison every statistic above p90.</p><p><strong>Warmup is a strict phase.</strong> Warmup requests fully complete before measurement begins, even under concurrency, so connection establishment and server-side cache effects never leak into the measured distribution.</p><p>None of this is novel. It is standard practice from systems performance work, applied to a domain where, for some reason, it is not yet standard.</p><h3>The part where I tell you it found a bug in itself</h3><p>While reviewing the tool before release I found that my own first implementation committed several of the sins it was built to catch. The ITL “p99” was computed from per-request averages. Throughput included TTFT. The timeout flag was accepted and silently ignored. Warmup requests ran concurrently with measured ones under high concurrency.</p><p>Each of these produces plausible-looking numbers. That is what makes measurement bugs worse than crashes: a crash announces itself, a subtly wrong percentile gets quoted in a blog post.</p><p>The fix for all of them was the same discipline: write down what the metric is supposed to mean, then check the code computes exactly that and nothing else. The test suite now includes a case where 2 spike gaps hide among 98 fast ones, and asserts that pooled p99 surfaces 500ms while per-request averaging would have reported 12ms.</p><h3>Try it</h3><p>Repo: <a href="https://github.com/saksham10arora-dotcom/llm-bench">github.com/saksham10arora-dotcom/llm-bench</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cv5H0iQQ_8Q9Dzts.png" /></figure><p><em>MIT licensed, with a mock provider so you can run the full pipeline without an API key.</em></p><p>If you disagree with any measurement decision, the Methodology section of the README is the place to start the argument. That is what it is there for.</p><p><strong>Update (v0.2.0):</strong> llm-bench is now on PyPI. pip install llm-latency-bench. Also ships a --task flag ( text, code, pdf, image, chat) after feedback from a Sr DS at Meta that task type is upstream of any latency number: the metric profile that matters for batch PDF processing at night is completely different from interactive code gen. The flag adds that context to every benchmark output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NJvpqAPDxaP2jMA0.png" /></figure><p><em>Now on PyPI as </em><em>llm-latency-bench.</em></p><p><em>Originally published at </em><a href="http://saksham.digital/blog/the-average-latency-lie"><em>https://saksham.digital</em></a><em> on June 18, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=221fe34d72e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built an HFT Matching Engine (And All The Things I Got Wrong)]]></title>
            <link>https://nerfsaksham.medium.com/how-i-built-an-hft-matching-engine-and-all-the-things-i-got-wrong-c54ab38da090?source=rss-9f8259d762ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/c54ab38da090</guid>
            <category><![CDATA[hft]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[design-systems]]></category>
            <dc:creator><![CDATA[Saksham Arora]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 18:21:31 GMT</pubDate>
            <atom:updated>2026-11-04T13:36:49.273Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jEuwDb7yGWPV7DcS.png" /></figure><p>I’m a second-year CSE undergrad. A few months ago I decided to build a limit order book matching engine in C++, the kind that sits inside exchanges and matches buy/sell orders.</p><p>Here’s the honest story of how it went from a fake benchmark to a real system processing 2.7 million orders per second.</p><h3>The starting point: I had no idea what I was doing</h3><p>I knew I wanted to build “something HFT” because it sounded impressive. I didn’t really understand what an order book was. I Googled “limit order book C++” and cobbled together a basic version:</p><ul><li>std::map for storing price levels (because sorted, right?)</li><li>std::vector for storing orders at each price</li><li>double for prices (because money has decimals, right?)</li></ul><p>It compiled. It ran. I was proud.</p><p>Then I wrote a “stress test” that looked like this:</p><p>That’s not a stress test. That’s a for loop that multiplies by 2. Nothing touches the order book. But it said “2.5 billion TPS” and I put it on LinkedIn.</p><p><strong>Lesson 1: If your benchmark seems too good to be true, it probably is.</strong></p><h3>The first real bug: floating point prices</h3><p>Once I started actually matching orders, I hit a weird bug where identical prices wouldn’t match. Two orders at $100.50 would sometimes not cross:</p><p>This is the classic IEEE 754 floating point problem. Real exchanges don’t use floats for this exact reason.</p><p><strong>Fix:</strong> I switched everything to integer “ticks.” $100.50 becomes 10050. Integer comparison is always exact.</p><p><strong>Lesson 2: Never use floating point for money. I thought I knew this but had to learn it the hard way.</strong></p><h3>The humbling rewrite: actually measuring performance</h3><p>When I put the real matching logic under a proper timer, the numbers were… not great. About 800K orders/sec. Not terrible, but not the “millions of TPS” I had been claiming.</p><p>I ran a profiler (well, I added a bunch of chrono timing). The bottleneck was clear: std::map. Every time I inserted or looked up a price level, it was doing O(log n) tree traversal with pointer chasing.</p><p>I read Ulrich Drepper’s paper on memory and realized the problem: every std::map node is heap-allocated at a random address. The CPU cache can&#39;t predict where the next node is, so every access is a cache miss (~100ns penalty).</p><p><strong>Fix:</strong> I replaced std::map with a flat std::vector, one entry per possible price tick. Price 10050 goes into array[10050 - min_tick]. O(1) access, and the entries are contiguous in memory so the cache prefetcher pulls in adjacent levels for free.</p><p>This alone got me from 800K to 1.3M orders/sec. A 1.6x improvement from just changing the data structure for cache friendliness, the algorithm (addOrder + match) was basically the same.</p><p><strong>Lesson 3: Cache effects matter more than algorithmic complexity for small n.</strong></p><h3>The cancel problem: O(n) was killing me</h3><p>In real markets, a huge percentage of orders get cancelled. Market makers send an order, the price moves, they cancel it and send a new one. This happens constantly.</p><p>With std::deque as my order queue, cancelling meant scanning the entire queue to find the order:</p><p>O(n) per cancel. With thousands of orders per price level, this was brutal.</p><p><strong>Fix:</strong> Intrusive doubly-linked lists. Instead of putting orders INTO a container, each order carries its own prev and next pointers:</p><p>To cancel, you just relink the neighbors:</p><p>Three pointer operations. O(1). This was the single biggest performance win in the project.</p><p><strong>Lesson 4: Sometimes adding 16 bytes to a struct saves you from O(n) operations. The tradeoff is always worth thinking about.</strong></p><h3>The matching hot path: death by allocation</h3><p>I profiled again (more chrono timestamps) and found another bottleneck: the matching function was returning std::vector&lt;Trade&gt;. Every call to match() was:</p><ol><li>Construct a vector (malloc internally)</li><li>Push trades into it (possibly realloc)</li><li>Return it (move semantics help, but still)</li></ol><p>Over 2 million orders, that’s 2 million vector constructions. Each one hits the heap allocator.</p><p><strong>Fix:</strong> Callback templates. Instead of returning a vector, the caller passes a function:</p><p>For benchmarking, you pass [](const Trade&amp;) {}, a no-op. The compiler inlines it and removes it entirely. Zero cost.</p><p><strong>Lesson 5: On the hot path, every allocation counts. Callbacks beat return values when you need maximum throughput.</strong></p><h3>The result</h3><p>After all three changes (flat array + intrusive lists + callback matching), the benchmark looked like this:</p><p>3x faster. But the tail latency improvement was even more dramatic, p999 went from 45μs to 3.4μs. That’s 13x better worst-case behavior.</p><p>The most satisfying part was that the improvements were cumulative and each one had a clear explanation:</p><ul><li>Flat array: cache locality</li><li>Intrusive list: O(1) cancel</li><li>Callback: zero allocation</li></ul><h3>What I’d do differently next time</h3><ol><li><strong>Write the benchmark first.</strong> If I had a proper benchmark from day one, I wouldn’t have wasted time with the fake stress test.</li><li><strong>Read about real exchange architectures earlier.</strong> The LMAX Disruptor paper and the Drepper memory paper should have been my starting points.</li><li><strong>Add proper observability.</strong> I still don’t have nanosecond-precision logging. Adding timing around every operation would have helped me find bottlenecks faster.</li><li><strong>Don’t put impressive-sounding numbers on LinkedIn before verifying them.</strong> “2.5 billion TPS” from an empty for-loop is not a metric anyone should brag about.</li></ol><h3>What I actually learned</h3><p>This project taught me more about systems programming than any course or textbook. Not because the code is particularly complex, it’s ~1000 lines of C++17. But because every optimization forced me to understand a layer deeper:</p><ul><li>Why flat arrays beat trees → led me to understand CPU cache architecture</li><li>Why intrusive lists beat containers → led me to understand memory layout</li><li>Why callbacks beat return values → led me to understand compiler inlining</li></ul><p>If you’re a student looking to learn systems programming, I’d recommend building something like this. Not because the world needs another matching engine, but because the process of making it fast teaches you things you can’t learn any other way.</p><p><a href="https://github.com/saksham10arora-dotcom/Simple-HFT-Engine">GitHub repo</a></p><p>More of my writing and projects at <a href="https://saksham.digital/">saksham.digital</a>.</p><p><em>Originally published at </em><a href="http://dev.to/nerfsaksham/how-i-built-an-hft-matching-engine-and-all-the-things-i-got-wrong-e23"><em>https://dev.to</em></a><em> on April 13, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c54ab38da090" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>