RimWorld

RimWorld

EchoColony
**[BUG REPORT] EchoColony + Local Ollama: AI stops roleplaying as a colonist after a few turns, plus a red error in the log**
Hi EchoColony Mod author,

I've been using your EchoColony Mod with my locally deployed Ollama AI model recently and have encountered some issues I'd like to report.

Here are the main problems:

1. **AI breaks character after a few dialogue turns:** When I use the AI to converse with colonists, it usually stays in character for the first few turns (around 3 turns), roleplaying as a colonist according to the global prompt I set. However, after about 3-4 turns, the AI starts to say things a colonist wouldn't. Sometimes it identifies itself as an "AI assistant" or gives very generic responsesشارة to the colonist's persona.
2. **Red error in the log:** In RimWorld's `Player.log` file, I've seen a red error message: `Could not find player faction.` This is followed by a long call stack pointing to `EchoColony.Patch_Hediff:Postfix`. Regarding this red error, I noticed `Verse.Root_Play:SetupForQuickTestPlay ()` in the call stack. I'm guessing this error record might have been generated during developer quick game testing (QuickTestPlay) and might not be directly related to the AI dialogue issues I'm experiencing, but I'm mentioning it for your reference.

Here are the general steps I take to reproduce the problem:

1. Install the EchoColony Mod.
2. Set up the Mod to use my local Ollama service. The Ollama endpoint I entered is: `http://127.0.0.1:11434/api/generate`
3. The Ollama model I'm using is: `EntropyYue/chatglm3:6b`
4. My global prompt is set to: "You are a thoughtful RimWorld colonist. Please understand my words carefully and give your true thoughts or answers."
5. Then I start a new game or load a save.
6. Chat with a colonist for a few turns.
7. I can observe that the AI is fine at the beginning, but then it goes off track. At the same time, the red error mentioned above can be seen in the Player.log.

I've also tried some troubleshooting myself:

* My Ollama service itself is working correctly. Using the `curl` command to directly access the `/api/generate` endpoint, the model responds normally.
* I've also tried a few different global prompts, but the issue of the AI going off track after a few turns still occurs.
* **(Important: Please fill this in based on your actual actions)** Regarding conflicts with other AI Mods, I [Explain whether you have disabled other AI Mods like RimGPT and the situation after disabling them. For example: "I have already disabled RimGPT and the problem still exists with only EchoColony active." or "I haven't had a chance to try disabling other Mods yet."].

Here's the complete red error from Player.log:
```
Could not find player faction.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
RimWorld.Faction:get_OfPlayer ()
EchoColony.Patch_Hediff:Postfix (Verse.Pawn_HealthTracker,Verse.Hediff)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Pawn_HealthTracker.AddHediff_Patch1 (Verse.Pawn_HealthTracker,Verse.Hediff,Verse.BodyPartRecord,System.Nullable`1<Verse.DamageInfo>,Verse.DamageWorker/DamageResult)Verse.PawnGenerator:TryGenerateNewPawnInternal (Verse.PawnGenerationRequest&,string&,bool,bool)
Verse.PawnGenerator:GenerateNewPawnInternal (Verse.PawnGenerationRequest&)
Verse.PawnGenerator:GenerateOrRedressPawnInternal (Verse.PawnGenerationRequest)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.PawnGenerator.GeneratePawn_Patch1 (Verse.PawnGenerationRequest)
RimWorld.Faction:TryGenerateNewLeader ()
RimWorld.FactionGenerator:NewGeneratedFaction (RimWorld.FactionGeneratorParms)
RimWorld.FactionGenerator:CreateFactionAndAddToManager (RimWorld.FactionDef)
RimWorld.FactionGenerator:AddFactionToManager (RimWorld.FactionDef)
RimWorld.FactionGenerator:GenerateFactionsIntoWorld (System.Collections.Generic.List`1<RimWorld.FactionDef>)
RimWorld.Planet.WorldGenStep_Factions:GenerateFresh (string)
RimWorld.Planet.WorldGenerator:GenerateWorld (single,string,RimWorld.Planet.OverallRainfall,RimWorld.Planet.OverallTemperature,RimWorld.Planet.OverallPopulation,System.Collections.Generic.List`1<RimWorld.FactionDef>,single)
Verse.Root_Play:SetupForQuickTestPlay ()
RimWorld.MainMenuDrawer/<>c:<DoMainMenuControls>b__24_10 ()Verse.LongEventHandler:RunEventFromAnotherThread (System.Action)
Verse.LongEventHandler/<>c:<UpdateCurrentAsynchronousEvent>b__28_0 ()System.Threading.ThreadHelper:ThreadStart_Context (object)
System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)
System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object)
System.Threading.ThreadHelper:ThreadStart ()
```

My personal guess:
When the AI goes off track after a few turns, it feels like the Mod might be forgetting or truncating the earlier parts of the conversation history (context) when processing it. That's why the AI might forget its initial character settings. As for the `Could not find player faction.` red error, like I said, the stack trace seems related to developer quick testing, so maybe it's not a big deal for my AI dialogue problem, but you can take another look.

I hope this helps you investigate the issue. The idea behind the Mod itself is very cool! Thanks for your development work!
Last edited by 水晶哥牌音响; Jun 4 @ 10:33pm