di-sukharev / di-sukharev/opencommit

[Bug]: `400` Error When Using Reasoning Model ("o1-mini")

Open
#442 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
7.5k
Forks
445
Avg merge
18m
Merged PRs (30d)
2

Description

Opencommit Version

3.2.5

Node Version

22.13.0

NPM Version

10.9.2

What OS are you seeing the problem on?

Other Linux Distro

What happened?

OpenAI’s family of reasoning models (e.g. o1, o1-mini) do not accept system messages.
When I configured OpenCommit with OCO_MODEL=o1-mini and tried to generate a commit,
the process failed with an HTTP 400 error indicating 'messages[0].role' does not support 'system' for this model.

Expected Behavior

I expected OpenCommit to successfully generate a commit message for these new reasoning models without error.

Current Behavior

The process immediately stops with a HTTP 400 “unsupported_value” error if the first message is system. It never proceeds to generate the commit message.

Possible Solution

A solution might be to detect these models (“reasoning” family) in OpenAiEngine.generateCommitMessage()
and remove or merge any system message content into the user prompt.
This ensures the request is valid for those models.

Feature request #441 has been opened for this and includes more detail on possible solution implementations.

Steps to Reproduce
  1. oco config set OCO_MODEL=o1-mini
  2. Optionally set OCO_TOKENS_MAX_INPUT=128000 and OCO_TOKENS_MAX_OUTPUT=65536
  3. Stage a few file changes and run oco
  4. Observe the 400 error about 'system' role not supported
Relevant log output
$ oco
┌  open-commit
│
◇  9 staged files:
  .cspell.json
  .editorconfig
  .github/dependabot.yml
  .github/workflows/ci.yml
  .github/workflows/spellcheck.yml
  .gitignore
  .markdownlint.yaml
  .vscode/extensions.json
  lychee.toml
│
◇  ✖ Failed to generate the commit message
BadRequestError3: 400 Unsupported value: 'messages[0].role' does not support 'system' with this model.
    at APIError3.generate (path/to/lib/node_modules/opencommit/out/cli.cjs:60664:14)
    at OpenAI.makeStatusError (path/to/lib/node_modules/opencommit/out/cli.cjs:60213:22)
    at OpenAI.makeRequest (path/to/lib/node_modules/opencommit/out/cli.cjs:60256:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async OpenAiEngine.generateCommitMessage (path/to/lib/node_modules/opencommit/out/cli.cjs:63730:28)
    at async generateCommitMessageByDiff (path/to/lib/node_modules/opencommit/out/cli.cjs:64405:27)
    at async generateCommitMessageFromGitDiff (path/to/lib/node_modules/opencommit/out/cli.cjs:64617:25)
    at async trytm (path/to/lib/node_modules/opencommit/out/cli.cjs:64584:18)
    at async commit (path/to/lib/node_modules/opencommit/out/cli.cjs:64786:35) {
  status: 400,
  headers: {
    'access-control-expose-headers': 'X-Request-ID',
    'alt-svc': 'h3=":443"; ma=86400',
    'cf-cache-status': 'DYNAMIC',
    'cf-ray': 'REDACTED',
    connection: 'keep-alive',
    'content-length': '221',
    'content-type': 'application/json',
    date: 'Sun, 12 Jan 2025 00:31:44 GMT',
    'openai-organization': 'user-REDACTED',
    'openai-processing-ms': '13',
    'openai-version': '2020-10-01',
    server: 'cloudflare',
    'set-cookie': '__cf_bm=REDACTED; path=/; expires=Sun, 12-Jan-25 01:01:44 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=REDACTED; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None',
    'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
    'x-content-type-options': 'nosniff',
    'x-ratelimit-limit-requests': '500',
    'x-ratelimit-limit-tokens': '200000',
    'x-ratelimit-remaining-requests': '499',
    'x-ratelimit-remaining-tokens': '195903',
    'x-ratelimit-reset-requests': '120ms',
    'x-ratelimit-reset-tokens': '1.228s',
    'x-request-id': 'REDACTED'
  },
  request_id: 'REDACTED',
  error: {
    message: "Unsupported value: 'messages[0].role' does not support 'system' with this model.",
    type: 'invalid_request_error',
    param: 'messages[0].role',
    code: 'unsupported_value'
  },
  code: 'unsupported_value',
  param: 'messages[0].role',
  type: 'invalid_request_error'
}
│
└  ✖ 400 Unsupported value: 'messages[0].role' does not support 'system' with this model.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at OpenAiEngine.generateCommitMessage(), the entry point named in the report, and inspect how the system and user messages are assembled. Reproduce with OCO_MODEL=o1-mini and staged changes, then verify that reasoning models generate a commit message without the unsupported system-role error while other models continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
ai, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.