# Building a Serverless AI Fantasy Football Manager Agent

Automating NFL roster management using Google Gemini and Mixed-Integer Linear Programming.

- **Source:** [Hacker News: Show HN](https://news.ycombinator.com)
- **Published:** 2026-10-15
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://github.com/nvbd6sgabzxy/fantasy-manager>
- **On Brifing:** https://brifing.si/s/01841a94-bbef-45cc-a03a-1af265c87353

## Automated Fantasy Roster Management

The Fantasy Manager agent provides automated team advice by integrating real-time NFL data directly into Discord. It aggregates information from ESPN league data, Sleeper trends, and RotoWire breaking news. By leveraging Google Gemini, the system classifies roster updates and trade opportunities, ensuring users receive timely notifications to keep their fantasy lineups competitive.

## Optimization via Linear Programming

The agent utilizes Mixed-Integer Linear Programming to maximize projected points for starting lineups. It dynamically computes optimal bench strategies based on specific league configurations and roster sizes. While the AI classifies news and player data, the solver algorithm handles the mathematical optimization, providing users with actionable diff-style change suggestions for their teams.

## Serverless Workflow Architecture

The system operates on a serverless architecture using Cloudflare Workers for polling external RSS feeds. These workers utilize Cloudflare KV to deduplicate news items before triggering GitHub Actions. This event-driven approach ensures that the Python-based manager script only executes when necessary, maintaining efficiency while processing multi-source data aggregation and LLM inference tasks.

## GitHub Actions Integration

GitHub Actions serves as the primary execution environment for the Python manager script. Upon receiving a repository_dispatch event, the environment installs dependencies and runs the main logic. The script includes robust retry mechanisms for LLM inference, ensuring that structured results are successfully posted to the designated Discord channel for the user.

## Configuration and Deployment Requirements

Users must configure several environment secrets, including Gemini API keys and ESPN credentials like League ID and SWID. Deployment requires setting up two distinct Cloudflare workers: one for the manager trigger running every ten minutes, and another for injury data updates. These workers must be deployed using the Wrangler CLI tool.

## Data Source Aggregation Strategy

The agent synthesizes data from disparate sources to inform its decision-making process. By combining ESPN league-specific data with broader NFL depth charts and injury reports, the system creates a comprehensive view of player value. This multi-layered data approach allows the AI to classify news effectively before feeding it into the solver.

## Technical Constraints and Risks

The project is currently a proof-of-concept developed shortly before the NFL season began. It has undergone limited testing over a few active weeks. Users are advised to use the tool at their own risk, as the reliance on external APIs and webhooks requires ongoing maintenance and careful management of private credentials.

## Future Development and Contribution

As an open-source repository, the project welcomes community contributions and pull requests to improve its functionality. The current implementation relies on specific models like gemini-3.6-flash, but the modular design allows for future model swaps or logic enhancements. This framework demonstrates the potential for combining LLMs with traditional optimization algorithms in sports.

## Sources covering this story

- https://github.com/nvbd6sgabzxy/fantasy-manager — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
