{"slug": "my-commit-message-said-you-ve-hit-your-session-limit", "title": "My commit message said \"You've hit your session limit\"", "summary": "A developer replaced Claude with a local Ollama model for generating git commit messages after hitting Claude's usage limit, which resulted in a commit message reading 'You've hit your session limit'. The developer chose the quantized qwen2.5-coder:1.5b model for its small size and low memory footprint, but found that Ollama's default context window of 4096 tokens caused the model to produce inaccurate commit messages based on partial diffs. By creating a Modelfile with an increased context window of 8192 tokens and a lower temperature of 0.2, the developer improved the model's performance for this task.", "body_md": "I had this one-liner that I was using.\n\n```\ngit commit -m \"$(git diff --staged | claude -p \"Provide a simple, one-line git commit message based on this diff following best practices. Output absolutely nothing else.\")\"\n```\n\nPipe the staged diff to Claude, get a commit message back. Worked well until I hit my Claude usage limit mid commit. The shell captured the error instead of a commit message.\n\nSo I had a commit in my repo that said:\n\nYou've hit your session limit\n\nThat's when it hit me! Voila, ✨My use case for a Local Model.✨\n\n[Ollama](https://ollama.com/) lets you run open source models locally. After installing it, you have a server running at `http://localhost:11434`\n\n.\n\n```\nollama pull qwen2.5-coder:1.5b\n```\n\nI picked `qwen2.5-coder:1.5b`\n\nbecause it's small and code-aware.\n\nWhy 1.5b specifically? My laptop has 8GB RAM. That's not a lot when you're running a model locally.\n\nHere's the rough math (these are estimates from my machine, yours may vary):\n\nInterestingly, despite being a 1.5 billion parameter model, qwen2.5-coder:1.5b only takes up about 1 GB of disk space. That's because it's a quantized model.\n\n[Quantization](https://huggingface.co/docs/optimum/en/concept_guides/quantization) means the [model's weights](https://www.ultralytics.com/glossary/model-weights#model-weights-vs-biases) are stored at lower precision, using 4-bit or 8-bit integers instead of the usual 16-bit or 32-bit floating point numbers. This significantly reduces the model size and memory footprint, although it may slightly impact accuracy.\n\nI tried larger models. My laptop became unusable. Fans spinning, apps freezing, the whole thing. So 1.5b it is.\n\nThere's another quantized model I found that could work — `gemma3:1b-it-qat`\n\n. I plan to test it sometime and see how it compares in terms of performance and resource usage.\n\nI swapped Claude with Ollama in my one-liner:\n\n```\ngit commit -m \"$(git diff --staged | ollama run qwen2.5-coder:1.5b \"Provide a simple, one-line git commit message based on this diff following best practices. Output absolutely nothing else.\")\"\n```\n\nI ran it against a change where I had removed the `tools`\n\nsection from some agent config front matter from 6 files. This Worked\n\nThe commit message said it was a change to a README file.\n\nDespite qwen2.5-coder:1.5b's large native context window of 32,768 tokens, Ollama actually restricts the default context size when running without a Modelfile.\n\nI checked Ollama's logs and found this line:\n\n```\nlevel=INFO source=routes.go:2073 msg=\"vram-based default context\" total_vram=\"5.3 GiB\" default_num_ctx=4096\n```\n\nIt shows that based on my machine's VRAM of 5.3 GiB, Ollama set a default `num_ctx`\n\nof 4096 tokens. That's why the model only saw the beginning of the diff and guessed about the README file.\n\nI thought maybe I need a better prompt. So I ran it again with more instructions.\n\nThis time it said the change was in `code-reviewer.md`\n\n. That was one of the 6 files, and it completely ignored the other 5.\n\nThe important thing here is that the model did not complain. It did not say \"I couldn't read the rest\". It just gave me a confident answer based on partial input.\n\nAt this point I understood tuning the prompt alone is insufficient and I need to tune the model too.\n\nThis is something I just learned. A Modelfile is a config layer on top of a base model. You can change parameters and create a named model from it.\n\n```\nFROM qwen2.5-coder:1.5b\n\nPARAMETER num_ctx 8192 \nPARAMETER temperature 0.2\n```\n\nTwo things I changed:\n\n`num_ctx 8192`\n\n— While qwen2.5-coder:1.5b can handle up to 32k tokens natively, Ollama defaults to a smaller context window when run without a Modelfile (in my case, 4096 based on VRAM). I bumped it to 8k, and be memory-efficient on my 8GB machine.\n\n`temperature 0.2`\n\n— lower temperature for more predictable output. For commit messages I don't want creative, I want consistent.\n\n```\nollama create qwen-commit -f ./Modelfile\n```\n\nNow I have a model called `qwen-commit`\n\nthat I can use for this specific task.\n\nBy the way, a Modelfile is not the only way to set these. You can use the REST API directly, and pass an `options`\n\nobject:\n\n```\ncurl http://localhost:11434/api/generate -d '{\n  \"model\": \"qwen2.5-coder:1.5b\",\n  \"prompt\": \"${YOUR_PROMPT}\",\n  \"options\": {\n    \"temperature\": 0.2,\n    \"num_ctx\": 8192\n  }\n}'\n```\n\nFor my use case the Modelfile made more sense because I just want to call `ollama run qwen-commit`\n\nand have everything pre-configured.\n\nWith the bigger context window, the model could now see all 6 files. But it still described the change as \"⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ ⠋\n\n``diff feat(.opencode/agent): update tool list for code-reviewer, frontend-enginee frontend-engineer, go-backend-engineer, project-lead, req requirements-analyst, solution-architect`\n\n\". Better, Mouthful but wrong.\n\nThe model was reading the full diff now but commit message was technically correct, but nothing like what we would write in a commit message. Look at how it had `frontend-enginee frontend-engineer`\n\nor `req requirements-analyst`\n\nSo I changed the prompt. Instead of making the model figure it out, I just told it.\n\n```\nbash\naffected_files=$(git diff --staged --name-only | paste -sd, -)\n```\n\nThen added to the prompt: `\"Note that the changes are located in these files: [$affected_files]\"`\n\nAfter this the commit messages got much better. The model didn't have to guess anymore.\n\nThe commit messages were now accurate but the model kept wrapping them in weird formatting despite the prompt saying not to. Sometimes backticks. Sometimes it prefixed with \"diff\". Sometimes random quotes around the message.\n\nSo I added a cleanup step to strip all of that out:\n\n```\nbash\nmsg=$(echo \"$msg\" | tr -d '\\r' | sed -E \\\n  -e 's/\n\n```(diff)?//g' \\\n  -e 's/^diff[[:space:]]+//I' \\\n  -e 's/^[[:space:]]+//;s/[[:space:]]+$//' \\\n  -e 's/^[\"'\\'']//' -e 's/[\"'\\'']$//')\n```\n\nNot elegant but it catches most of the junk the model adds. Till the time I tune the prompt and model this stays!\n\nI also switched from `git diff --staged`\n\nto `git diff --staged --unified=0`\n\n. By default, git shows 3 lines of context around each change. For a commit message, the model doesn't need that surrounding context. It just needs to know what changed. `--unified=0`\n\nstrips all that out, which means fewer tokens sent to the model. On a small context window, every token counts.\n\nTada 🎉\n\n``` php\n* b6f0abc (HEAD -> main, origin/main, origin/HEAD) fix: update tool list for all agents\n```\n\nMuch bigger code related commit, you can see gradual improvements.\n\n``` php\n* b13f344 (HEAD -> main) fix(inspection-workflow): add requirement for editing confirmed vess vessel profile\n* 958053c sh fix(app_test.go, sqlite.go, sqlite_test.go, tasks.md): add save and cancel  behaviour tests for vessel profile editing\n* 0f33259 sh fix: update vessel profile form and edit flow in App.svelte, add tests for  editing workflow, and improve styles in styles.css, update model in go/mode go/models.ts\n```\n\nAfter all the iterations, my Modelfile looks quite different from where I started:\n\n```\nFROM qwen2.5-coder:1.5b\n\nPARAMETER num_ctx 8192\nPARAMETER temperature 0.2\nPARAMETER top_p 0.7\nPARAMETER num_predict 256\nPARAMETER repeat_penalty 1.2\nPARAMETER stop \"Changes to be committed:\"\nPARAMETER stop \"Note:\"\nSYSTEM \"\"\"\nYou are an expert developer's assistant. Your sole task is to generate a clean, concise one-line Git commit message based on the provided code diff.\nRules:\n- Respond ONLY with the commit message text.\n- Do NOT include markdown code blocks, backticks, explanations, intro text, or outro text.\n- Use the Conventional Commits format (e.g., feat(scope): message, fix: message).\n- Keep the one line under 100 characters.\n- Use the imperative mood (\"Add feature\", not \"Added feature\" or \"Adds feature\").\n\"\"\"\n```\n\nWhat each parameter does and why I added it:\n\n`temperature 0.2`\n\n: controls randomness. Lower means more predictable. I don't want creative commit messages.\n\n`top_p 0.7`\n\n: works with temperature. It limits the model to only consider the top 70% most likely next words. Another way to keep the output focused and not wander off.\n\n`num_predict 256`\n\n: maximum number of tokens the model can output. A commit message is one line. I don't need the model writing an essay. This caps it.\n\n`repeat_penalty 1.2`\n\n: penalizes the model for repeating itself. Without this I was getting things like `frontend-enginee frontend-engineer`\n\nor `req requirements-analyst`\n\n. The model would stutter and repeat parts of words.\n\n`stop \"Changes to be committed:\"`\n\nand `stop \"Note:\"`\n\n— stop sequences. Sometimes the model would keep going after the commit message and start generating text that looked like git output. These tell the model to stop immediately if it starts outputting these strings.\n\nThe `SYSTEM`\n\nblock is the prompt baked into the model. Every time I run `ollama run qwen-commit`\n\n, this prompt is already there. I don't have to pass it every time.\n\nAfter all the iterations, here is what I ended up with. A custom shell function `gac`\n\nand an alias `gacc`\n\n. It defaults to the local model, but I can also use Claude when I want to.\n\n```\ngac() {\n  # 1. Check for staged changes\n  if git diff --cached --quiet; then\n    echo \"❌ Error: No staged changes found. Run 'git add' first.\"\n    return 1\n  fi\n\n  local mode=\"${1:-qwen}\"\n  local msg=\"\"\n  local exit_code=0\n\n  # Gather file names for context\n  local affected_files\n  affected_files=$(git diff --staged --name-only | paste -sd, -)\n\n  # ---------------------------------------------------------\n  # IMPROVED PROMPT: Strict rules for Conventional Commits\n  # ---------------------------------------------------------\n  local system_prompt=\"You are a strict code assistant. Write a single-line Conventional Commit message for the provided diff.\nStrict Rules:\n1. Format must exactly match: type(scope): description\n2. Allowed types ONLY: feat, fix, docs, style, refactor, perf, test, chore.\n3. The 'scope' must be a single, broad feature/module name (e.g., vessel-profile, api). NEVER use file names.\n4. The 'description' must summarize the high-level intent in the imperative mood (e.g., 'add form validation').\n5. ABSOLUTELY DO NOT list specific file names, paths, or extensions in the commit message.\n6. Output EXACTLY one line. No markdown blocks, no quotes, no explanations, and no stray prefixes like 'sh'.\nContext: The files modified are [$affected_files].\"\n\n  # 2. Execution Routing\n  if [ \"$mode\" = \"claude\" ]; then\n    msg=$(git diff --staged --unified=0 | claude -p \"$system_prompt\" --output-format text 2>&1)\n    exit_code=$?\n  else\n    if ! curl -s --max-time 2 http://localhost:11434 > /dev/null; then\n      echo \"❌ Error: Local Ollama server is not running on port 11434.\"\n      return 1\n    fi\n    msg=$(git diff --staged --unified=0 | ollama run qwen-commit \"$system_prompt\" 2>/dev/null)\n    exit_code=$?\n  fi\n\n  # 3. Robust Error Validation\n  if [ $exit_code -ne 0 ] || [ -z \"$msg\" ]; then\n    echo \"❌ Error: Failed to generate a response via $mode.\"\n    echo \"Details received: $msg\"\n    return 1\n  fi\n\n  # 4. Strict Text Cleaning Pipeline\n  msg=$(echo \"$msg\" | tr -d '\\r' | sed -E -e 's/```(diff)?//g' -e 's/^[[:space:]]+//;s/[[:space:]]+$//' -e 's/^[\"'\\'']//' -e 's/[\"'\\'']$//')\n\n  # 5. Run git commit cleanly\n  git commit -m \"$msg\"\n}\n\n# Alias to explicitly force Claude\nalias gacc=\"gac claude\"\n```\n\nNo. It still sometimes misses the point of a change. It takes time on larger commits. There is room for improvement.\n\nWhy not just use Claude directly? That's the easiest thing to do, but it still costs me tokens. And I wanted to learn how local models work. How context windows affect output. How to tune a model for a specific job. That was the whole point for me.\n\nIt works offline, costs nothing 💰, and I understand every piece because I broke it and fixed it.\n\nI find the best way to learn is to find a real use case, however trivial. It helps you understand concepts one thing at a time.\n\n*Next up: My learnings building a green field product with OpenSpec meant for Brown field projects*\n\n*I welcome all constructive feedback and comments*", "url": "https://wpnews.pro/news/my-commit-message-said-you-ve-hit-your-session-limit", "canonical_source": "https://dev.to/shyamala_u/my-commit-message-said-youve-hit-your-session-limit-2abn", "published_at": "2026-06-29 15:15:49+00:00", "updated_at": "2026-06-29 15:19:21.100932+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "ai-tools"], "entities": ["Ollama", "Claude", "qwen2.5-coder:1.5b", "Modelfile", "gemma3:1b-it-qat"], "alternates": {"html": "https://wpnews.pro/news/my-commit-message-said-you-ve-hit-your-session-limit", "markdown": "https://wpnews.pro/news/my-commit-message-said-you-ve-hit-your-session-limit.md", "text": "https://wpnews.pro/news/my-commit-message-said-you-ve-hit-your-session-limit.txt", "jsonld": "https://wpnews.pro/news/my-commit-message-said-you-ve-hit-your-session-limit.jsonld"}}