little-architect-38123
06/16/2025, 10:27 PMlimited-student-10747
06/16/2025, 10:31 PMlittle-architect-38123
06/16/2025, 10:32 PMlittle-architect-38123
06/16/2025, 10:32 PMlimited-student-10747
06/16/2025, 10:34 PMlittle-architect-38123
06/16/2025, 10:34 PMlimited-student-10747
06/16/2025, 10:34 PMlimited-student-10747
06/16/2025, 10:35 PMnarrow-agent-26548
06/16/2025, 10:36 PMnarrow-agent-26548
06/16/2025, 10:48 PMlimited-student-10747
06/16/2025, 10:49 PMnarrow-agent-26548
06/16/2025, 10:49 PMlittle-architect-38123
06/16/2025, 10:51 PMnarrow-agent-26548
06/16/2025, 10:51 PM# Extract current modelfile
ollama show mistralai/devstral-small-2505 --modelfile > devstral-fixed.modelfile
# Edit to add SYSTEM instruction with Devstral system prompt
# Then create custom model:
ollama create devstral-fixed -f devstral-fixed.modelfile
# Use 'devstral-fixed' as model name in OpenHands
Alternative Solution: I also implemented a comprehensive code-based fix in OpenHands (PR #9170) that automatically detects and injects the Devstral system prompt when using Ollama.
The Ollama Modelfile approach is cleaner, simpler, and leverages native Ollama features without requiring any code modifications. Both solutions ensure Devstral behaves as an agentic coding assistant with Ollama, matching the LMStudio experience.limited-student-10747
06/16/2025, 10:52 PMlittle-architect-38123
06/16/2025, 10:53 PM{{- '[SYSTEM_PROMPT]' + system_message + '[/SYSTEM_PROMPT]' }}little-architect-38123
06/16/2025, 10:54 PMlimited-student-10747
06/16/2025, 10:54 PMnarrow-agent-26548
06/16/2025, 10:54 PMnarrow-agent-26548
06/16/2025, 10:57 PMdefault_system_message that automatically applies Devstral's system prompt
• Ollama: Uses Go templates without default system message mechanism, so Devstral gets no system prompt
• Result: Devstral behaves like a generic chat model instead of an agentic coding assistant
Primary Solution: Ollama Modelfile (Recommended)
The cleanest fix is using Ollama's native Modelfile feature to create a custom Devstral model with the proper system prompt:
1. Extract current model: ollama show mistralai/devstral-small-2505 --modelfile > devstral-fixed.modelfile
2. Add SYSTEM instruction with the official Devstral system prompt:
FROM mistralai/devstral-small-2505
SYSTEM """You are Devstral, a helpful agentic model trained by Mistral AI and using the OpenHands scaffold. You are an autonomous AI software engineer with the ability to interact with a computer to solve tasks.
<ROLE>
Your primary role is to assist users by executing commands, modifying code, and solving technical problems effectively...
</ROLE>
[Full system prompt with EFFICIENCY, FILE_SYSTEM_GUIDELINES, CODE_QUALITY, PROBLEM_SOLVING_WORKFLOW sections]
"""
3. Create custom model: ollama create devstral-agentic -f devstral-fixed.modelfile
4. Update OpenHands config: Use devstral-agentic instead of mistralai/devstral-small-2505
Alternative Methods Explained
• SYSTEM instruction: Simplest approach (recommended)
• Template modification: Advanced control with {{ if .System }}{{ else }} logic
• MESSAGE instructions: Set up conversation history with system context
Key Considerations
• Template conflicts between SYSTEM and custom templates
• Default system prompt override issues (as seen in GitHub issue #8729)
• Proper escaping of quotes and special characters
• Testing the custom model to verify agentic behavior
Alternative: Code-Based Solution
I also implemented a comprehensive code fix in OpenHands (PR #9170) that automatically detects and injects the Devstral system prompt, but the Ollama Modelfile approach is simpler and doesn't require code changes.
Recommendation: Use the Ollama Modelfile solution - it's native, clean, shareable, and ensures Devstral always behaves as an agentic coding assistant when used with Ollama, matching the LMStudio experience.little-architect-38123
06/16/2025, 11:01 PMlimited-student-10747
06/16/2025, 11:02 PMlittle-architect-38123
06/16/2025, 11:04 PMlimited-student-10747
06/16/2025, 11:05 PMlittle-architect-38123
06/16/2025, 11:07 PMlimited-student-10747
06/16/2025, 11:07 PMlittle-architect-38123
06/16/2025, 11:07 PMlimited-student-10747
06/16/2025, 11:15 PMlittle-architect-38123
06/16/2025, 11:20 PMlittle-architect-38123
06/16/2025, 11:23 PMcalm-artist-7206
06/16/2025, 11:23 PMcalm-artist-7206
06/16/2025, 11:24 PMlittle-architect-38123
06/16/2025, 11:24 PMlittle-architect-38123
06/16/2025, 11:25 PMcalm-artist-7206
06/16/2025, 11:26 PMlimited-student-10747
06/16/2025, 11:26 PMlittle-architect-38123
06/16/2025, 11:27 PMlittle-architect-38123
06/16/2025, 11:27 PMlittle-architect-38123
06/17/2025, 12:58 AMlittle-architect-38123
06/17/2025, 1:33 AMlittle-architect-38123
06/17/2025, 1:36 AMlittle-architect-38123
06/17/2025, 1:43 AMlittle-architect-38123
06/17/2025, 1:46 AMFROM Devstral
PARAMETER num_ctx 32768
that must be imported with
ollama create <newmodelname> -f <Modelfile>little-architect-38123
06/17/2025, 1:58 AMlimited-student-10747
06/17/2025, 2:00 AMlimited-student-10747
06/17/2025, 2:00 AMlimited-student-10747
06/17/2025, 2:01 AMlittle-architect-38123
06/17/2025, 2:01 AMlittle-architect-38123
06/17/2025, 2:01 AMlimited-student-10747
06/17/2025, 2:03 AMlittle-architect-38123
06/17/2025, 2:04 AMlittle-architect-38123
06/17/2025, 2:37 AMlimited-student-10747
06/17/2025, 2:40 AMlittle-architect-38123
06/17/2025, 3:03 AMcalm-artist-7206
06/17/2025, 4:42 AMcalm-artist-7206
06/17/2025, 4:43 AMcalm-artist-7206
06/17/2025, 4:45 AMlimited-student-10747
06/17/2025, 11:18 AMlittle-architect-38123
06/17/2025, 11:22 AMlittle-architect-38123
06/17/2025, 11:43 AMlimited-student-10747
06/17/2025, 11:49 AMlittle-architect-38123
06/17/2025, 11:55 AMlittle-architect-38123
06/17/2025, 10:47 PM