Inspiration

I read about world politics every single day. It’s always baffled me how brilliant leaders and even whole nations can end up in full gridlock. It’s rarely that someone is just, totally wrong. Most times the actual reason is that the incentives underneath don’t match up. It looks almost like one of those stalled climate treaty things, or a long standoff between superpowers, where nobody can move without paying some huge price later.

I’ve spent years staring at traps like this. Be it analyzing a chessboard, or racing against the clock during mental math championships, or just messing around with game theory, I keep seeing the same structure, again and again. For me, game theory is like the physics of human conflict. It explains why people who are rational and “doing the right thing” for themselves can still produce a pretty awful result for everyone else.

And the more I got into global negotiations, the more I noticed big tech companies run basically the same script. A product launch doesn’t fail because someone wrote bad code. It fails in the same way a treaty fails. Sales wants to close the deal, Engineering wants to avoid risk, and Legal is busy protecting the company. They sit in the same room, sure but they’re chasing different goals, and the tradeoffs are not aligned at all.

That’s why I built Nexus. I didn’t want to make one of those plain bots that only summarizes arguments. I wanted to build something that models the incentives for real, calculates the math under the disagreement, and basically shows you how to untangle it. I also realized that team friction isn’t just some communication mess. It behaves like a strict coordination game, and I wanted to write the code that can actually solve it.

How I built it

I used the Slack Bolt API in Python to handle all the asynchronous event listening directly inside the workspace. For the game theory engine, I used Gemini 3.1 Flash-Lite to extract unstructured chat data and map it into a strict $$N \times 2$$ payoff matrix. Once I had those cost and benefit variables, I wrote a script to run 500 Monte Carlo perturbations with Gaussian noise ($$\sigma = 1.5$$) to test if the Nash Equilibrium was actually stable. I also implemented a Granovetter threshold model to calculate if a sequential rollout could trigger a cascade effect among the teams.

For the codebase scanner, I built a static analysis tool using Python's native ast module. It traverses the Abstract Syntax Tree of the repository without running any code, making it completely secure. I fed that node data into networkx to calculate the betweenness centrality and find the exact structural bottleneck, which I then visualized as an interactive graph using pyvis. Finally, I set up the AI Architect pipeline to take that specific bottleneck and rewrite it safely using the Adapter design pattern.

Challenges I ran into

Getting an LLM to play nicely with deterministic math was extremely frustrating. Parsing casual Slack arguments into a strict utility matrix is highly volatile. I had to use a lot of few-shot prompting to force Gemini to output perfectly schema-validated JSON. If the JSON structure broke, my Monte Carlo simulation would just instantly crash.

I also struggled with the topological code scanning. Writing custom ast.NodeVisitor classes to track recursive imports across multiple files without timing out was a huge learning curve. Plus, figuring out how to bypass Slack's UI limits to dynamically serve an interactive HTML graph file took a lot of digging through the Slack API documentation.

What I learned

I learned that LLMs are way more powerful when you restrict them. By forcing the AI to just act as a data parser for my game theory models, I completely eliminated hallucinations. The bot could actually prove its answers mathematically instead of just generating text. I also got a massive crash course in static code analysis and compiler theory, which completely changed how I think about writing modular Python.

What's next for Nexus

Right now, Nexus mostly just looks at internal Slack arguments. The next big step is getting it to talk to the outside world, yeah. I wanna integrate it with this hyperinflation tracking tool I’ve been developing, it scrapes daily price information from commerce platforms and it compares that against the Consumer Price Index, CPI. If we feed real economic signals into the game theory engine then Nexus won’t only depend on what the Sales team says about delay costs, instead it will figure out the actual, real time economic cost of the gridlock.

I also plan to upgrade the underlying math. The current version uses a static Nash Equilibrium, but I want to implement dynamic, multi-stage games so the engine can model how different departments might compromise over a longer time horizon.

Built With

  • ast
  • game-theory
  • generative-ai
  • google-gemini
  • monte-carlo-simulation
  • nash-equilibrium
  • networkx
  • python
  • pyvis
  • slack-api
  • static-analysis
Share this project:

Updates

Submission history