RimWorld 1.6 · Prerequisite MOD: Harmony · Steam Workshop Page
Have you installed a bunch of mods and don't know how to arrange the load order? This mod can connect to Large Language Models (LLMs) to suggest a more reasonable load order based on your mod list and actual error logs.
To let the AI know which mods might be conflicting, the mod automatically intercepts errors during game startup/running in the background, analyzes which mod caused them, and records them as a reference for AI sorting. Therefore, the general usage is: play a session normally first (or at least load the game once) so the mod collects enough error information, and then use AI to sort. This yields better results.
Of course, the error analysis itself is also incredibly useful. Even if you don't use AI sorting, it can help you clearly see whose fault the red errors are.
This is the main feature of the mod. It is disabled by default and needs to be manually enabled in the Mod Settings, along with configuring the LLM's API Key.
Once enabled, the "Auto-sort" button in the mod list will trigger the AI process:
- Collect Basic Structure — To save tokens, the engine won't send the detailed descriptions of all mods. It only collects the names of all active mods and vanilla load requirements (like
loadBefore/loadAfterdependencies). - Extract Descriptions of Suspect Mods — Only "suspect mods" that have caused errors in the game will be passed to the LLM to shrink their descriptions into short summaries. (The results are cached locally so they don't need to be extracted again next time).
- Generate Soft Constraints — The condensed mod information and historical error records are submitted to the LLM, requesting sorting suggestions in the form of
loadBefore/loadAfter. - Topological Sort — The soft constraints returned by the AI are injected into the vanilla sorting engine, which then performs a topological sort.
So, for the AI to sort accurately, it's best to run the game once with your current mod list so the error analysis system can accumulate some data. It can still sort the first time you use it with no error data, but the AI will have less information to reference.
Note that AI sorting consumes API tokens. For instance, with 400 mods, the input will consume about 10k tokens.
This feature works automatically as soon as it's installed; no extra configuration is needed. It provides data for AI sorting, but it can also be used as a standalone troubleshooting tool.
When red errors occur in the game, the mod analyzes them from the following aspects:
- DLL Stack Trace Mapping — Extracts the assembly corresponding to each frame from the exception's call stack to find out which mod's DLL it is.
- XML Parsing Exception Localization — Intercepts the underlying XML processing routines, directly mapping the exact XML nodes that threw an exception back to their source files, mods, and specific XML NodePaths.
- Def Config Error Analysis — Intercepts Def configuration errors, traces their actual source files, extracts the entire
ParentNameinheritance chain, and identifies all Patch operations applied to that Def and its parent nodes. - Cross-Reference Sourcing — Deeply parses errors like
Could not resolve cross-referenceto track down the exact Def, file, and specific XML node that used the missing reference, and lists any involved Patches. - CE Compatibility Attribution — Resolves
no support for Combat Extendederrors by deeply analyzing stack frame parameters to pinpoint the specific item or race Defs that lack CE compatibility. - File Path & Workshop ID Extraction — Extracts local path strings from errors like
Cannot load textureor missing files, matching them to active mod root directories or decoding Steam Workshop IDs to find the mod.
The analysis results are saved to BetterModSort.Error.txt in the save directory, and the previous session's log is backed up as BetterModSort.Error.prev.txt.
Important
Tip for Bug Reporting: If you need to report bugs to other mod authors, please make sure to provide the full Player.log file or copy the original red error details from the log window. The BetterModSort.Error.txt generated by this mod only contains an analysis summary for AI sorting and quick reference, and may lack the critical technical details required by authors to fix bugs.
- Fully compatible with Mod Manager and Prestarter. Once you enable AI sorting in this mod's settings, clicking their native "Auto-sort" button will seamlessly trigger this mod's AI sorting process instead!
- RimSort Export: Supports automatically saving the current active mod list to a RimSort-compatible XML file after AI sorting completes (can be enabled in experimental settings).
- Subscribe to Better Mod Sort
- Ensure you are also subscribed to Harmony
- Activate them in the mod list, placing Harmony above this mod.
- Download the Release or clone this repository.
- Copy the contents of the
Assetsfolder toMods/BetterModSort/ - Compile the project and place the generated DLL in the
Assemblies/directory.
In the game, click Options → Mod Settings → Better Mod Sort to open.
- LLM API Key — Your API key. If left blank, AI features will be unavailable.
- LLM Base URL — API address, defaulting to
https://api.openai.com/v1/chat/completions. You can alter this to use compatible services like DeepSeek or Ollama. - LLM Model Name — The model name, defaulting to
gpt-4o.
- Enable AI-Assisted Sorting — Once checked, the "Auto-sort" button uses the AI process. Disabled by default.
- Max Error Log Characters Sent to AI — Limits the length of error content to prevent a single massive error from filling the context (Default: 8000).
- Max Raw Description Characters for Summary Extraction — Limits the length when extracting descriptions to save tokens (Default: 2500).
- LLM Request Timeout (seconds) — Sets the maximum waiting time for a single request (Default: 600).
- Enable Debug Dump — Writes a key summary of each LLM communication to a file to help troubleshoot issues caused by prompts. Files are located under
%LOCALAPPDATA%Low/Ludeon Studios/RimWorld by Ludeon Studios/BetterModSort/Dump/. - Open Data Folder — Clicking this in-game directly opens the mod's data storage directory via the file explorer, which contains
Dump(LLM communication summary logs),ShortDesc(AI-extracted Mod Desc summary cache), andBetterModSort.Error.txt(error analysis log file).
Currently supports English, Simplified Chinese, and Russian.
Translation files are located at Assets/Languages/<Language>/Keyed/BetterModSort.xml. Pull Requests to add more languages are welcome.
