Skip to content

[Bug]: Codex cancels on code diff rejection #3100

@vchernetskyi993

Description

@vchernetskyi993

Pre-submission checklist

  • I have read the documentation
  • I have updated the plugin and all dependencies to the latest versions
  • I have searched for existing issues and discussions
  • My issue is not a minor or cosmetic quirk (e.g., formatting, spacing, or other non-functional details)

Neovim version (nvim -v)

v0.12.0

Operating system/version

Ubuntu 24.04.4 LTS

Adapter and model

Codex and GPT-5.5

Describe the bug

Whenever I select Reject for code diff proposed by Codex ACP, I receive: You selected: Reject and the prompt immediately ends with ## Me ....

Also, I see a warning: [WARN] [acp:prompt_builder] Turn ended with stop_reason=cancelled.

Steps to reproduce

  1. Open CodeCompanionChat.
  2. Select Codex adapter.
  3. Ask for any code change.
  4. Reject.
  5. The whole prompt processing is cancelled.

Expected behavior

When using Copilot (with any model) during reject I am receiving vim.ui.input query with title Rejection reason, and when I enter the reason it is acknowledged by the model with message User rejected the edits for ... with the reason ..., and execution continues.

Also, similar behavior can be observed inside codex CLI itself (i.e., it proposes changes, user rejects and writes a reason, then Codex applies rejection suggestion).

Screenshots or recordings (optional)

No response

minimal.lua file

---@diagnostic disable: missing-fields

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

-- Your CodeCompanion setup
local plugins = {
	{
		"olimorris/codecompanion.nvim",
		dependencies = {
			{ "nvim-lua/plenary.nvim" },
			{
				"nvim-treesitter/nvim-treesitter",
				lazy = false,
				build = ":TSUpdate",
			},
		},
		opts = {
			adapters = {
				acp = {
					codex = function()
						return require("codecompanion.adapters").extend("codex", {
							defaults = {
								auth_method = "chatgpt",
							},
						})
					end,
				},
			},
			opts = {
				log_level = "DEBUG",
			},
		},
	},
}

require("lazy.minit").repro({ spec = plugins })

require("nvim-treesitter")
	.install({
		"lua",
		"markdown",
		"markdown_inline",
		"yaml",
	}, { summary = true, max_jobs = 10 })
	:wait(1800000)

Log output (optional)

[DEBUG] 2026-05-07 12:45:26
[acp] Process started: codex-acp
[DEBUG] 2026-05-07 12:45:26
[acp::connect_and_authenticate] Agent info: {
  agentCapabilities = {
    auth = {
      logout = vim.empty_dict()
    },
    loadSession = true,
    mcpCapabilities = {
      http = true,
      sse = false
    },
    promptCapabilities = {
      audio = false,
      embeddedContext = true,
      image = true
    },
    sessionCapabilities = {
      close = vim.empty_dict(),
      list = vim.empty_dict()
    }
  },
  agentInfo = {
    name = "codex-acp",
    title = "Codex",
    version = "0.13.0"
  },
  authMethods = { {
      description = "Use your ChatGPT login with Codex CLI (requires a paid ChatGPT subscription)",
      id = "chatgpt",
      name = "Login with ChatGPT"
    }, {
      description = "Requires setting the `CODEX_API_KEY` environment variable.",
      id = "codex-api-key",
      name = "Use CODEX_API_KEY",
      type = "env_var",
      vars = { {
          name = "CODEX_API_KEY"
        } }
    }, {
      description = "Requires setting the `OPENAI_API_KEY` environment variable.",
      id = "openai-api-key",
      name = "Use OPENAI_API_KEY",
      type = "env_var",
      vars = { {
          name = "OPENAI_API_KEY"
        } }
    } },
  protocolVersion = 1
}
[DEBUG] 2026-05-07 12:45:26
[acp] Initialized (protocol_version=1)
[DEBUG] 2026-05-07 12:45:26
[acp] Authenticated
[DEBUG] 2026-05-07 12:45:27
[acp] Config options: { {
    category = "model",
    currentValue = "gpt-5.5",
    description = "Choose which model Codex should use",
    id = "model",
    name = "Model",
    options = { {
        description = "Frontier model for complex coding, research, and real-world work.",
        name = "GPT-5.5",
        value = "gpt-5.5"
      }, {
        description = "Strong model for everyday coding.",
        name = "gpt-5.4",
        value = "gpt-5.4"
      }, {
        description = "Small, fast, and cost-efficient model for simpler coding tasks.",
        name = "GPT-5.4-Mini",
        value = "gpt-5.4-mini"
      }, {
        description = "Coding-optimized model.",
        name = "gpt-5.3-codex",
        value = "gpt-5.3-codex"
      }, {
        description = "Ultra-fast coding model (preview).",
        name = "gpt-5.3-codex-spark-preview",
        value = "gpt-5.3-codex-spark-preview"
      }, {
        description = "Optimized for professional work and long-running agents.",
        name = "gpt-5.2",
        value = "gpt-5.2"
      } },
    type = "select"
  }, {
    category = "thought_level",
    currentValue = "xhigh",
    description = "Choose how much reasoning effort the model should use",
    id = "reasoning_effort",
    name = "Reasoning Effort",
    options = { {
        description = "Fast responses with lighter reasoning",
        name = "Low",
        value = "low"
      }, {
        description = "Balances speed and reasoning depth for everyday tasks",
        name = "Medium",
        value = "medium"
      }, {
        description = "Greater reasoning depth for complex problems",
        name = "High",
        value = "high"
      }, {
        description = "Extra high reasoning depth for complex problems",
        name = "Xhigh",
        value = "xhigh"
      } },
    type = "select"
  } }
[DEBUG] 2026-05-07 12:45:27
[acp::_establish_session] New session config options applied
[DEBUG] 2026-05-07 12:45:27
[acp] Session established: 019e01d3-f17b-7a30-863e-c4d8097a1382
[DEBUG] 2026-05-07 12:45:27
[acp::commands] Registered 7 commands for session 019e01d3-f17b-7a30-863e-c4d8097a1382
[DEBUG] 2026-05-07 12:45:28
[acp] Config options: { {
    category = "model",
    currentValue = "gpt-5.5",
    description = "Choose which model Codex should use",
    id = "model",
    name = "Model",
    options = { {
        description = "Frontier model for complex coding, research, and real-world work.",
        name = "GPT-5.5",
        value = "gpt-5.5"
      }, {
        description = "Strong model for everyday coding.",
        name = "gpt-5.4",
        value = "gpt-5.4"
      }, {
        description = "Small, fast, and cost-efficient model for simpler coding tasks.",
        name = "GPT-5.4-Mini",
        value = "gpt-5.4-mini"
      }, {
        description = "Coding-optimized model.",
        name = "gpt-5.3-codex",
        value = "gpt-5.3-codex"
      }, {
        description = "Ultra-fast coding model (preview).",
        name = "gpt-5.3-codex-spark-preview",
        value = "gpt-5.3-codex-spark-preview"
      }, {
        description = "Optimized for professional work and long-running agents.",
        name = "gpt-5.2",
        value = "gpt-5.2"
      } },
    type = "select"
  }, {
    category = "thought_level",
    currentValue = "xhigh",
    description = "Choose how much reasoning effort the model should use",
    id = "reasoning_effort",
    name = "Reasoning Effort",
    options = { {
        description = "Fast responses with lighter reasoning",
        name = "Low",
        value = "low"
      }, {
        description = "Balances speed and reasoning depth for everyday tasks",
        name = "Medium",
        value = "medium"
      }, {
        description = "Greater reasoning depth for complex problems",
        name = "High",
        value = "high"
      }, {
        description = "Extra high reasoning depth for complex problems",
        name = "Xhigh",
        value = "xhigh"
      } },
    type = "select"
  } }
[DEBUG] 2026-05-07 12:45:28
[acp::set_config_option] Changed model to gpt-5.5
[INFO] 2026-05-07 12:45:45
Chat request started
[DEBUG] 2026-05-07 12:45:52
[ACP::Handler] Processing tool call {
  kind = "search",
  rawInput = {
    call_id = "call_lJu6nBoUzDtsLaAVGdbPDSiY",
    command = { "/bin/bash", "-lc", "rg --files -g '!*__pycache__*' | head -50" },
    cwd = "/home/chernetskyi/repo/personal/repros/codecompanion-codex-reject",
    parsed_cmd = { {
        cmd = "rg --files -g '!*__pycache__*'",
        path = vim.NIL,
        type = "list_files"
      } },
    process_id = "82706",
    source = "unified_exec_startup",
    turn_id = "019e01d4-3559-73f1-966c-697d5a729713"
  },
  sessionUpdate = "tool_call",
  status = "in_progress",
  title = "List /home/chernetskyi/repo/personal/repros/codecompanion-codex-reject",
  toolCallId = "call_lJu6nBoUzDtsLaAVGdbPDSiY"
}
[DEBUG] 2026-05-07 12:45:52
[ACP::Handler] Processing tool call {
  rawOutput = {
    aggregated_output = "minimal.lua\n",
    call_id = "call_lJu6nBoUzDtsLaAVGdbPDSiY",
    command = { "/bin/bash", "-lc", "rg --files -g '!*__pycache__*' | head -50" },
    cwd = "/home/chernetskyi/repo/personal/repros/codecompanion-codex-reject",
    duration = {
      nanos = 15271,
      secs = 0
    },
    exit_code = 0,
    formatted_output = "minimal.lua\n",
    parsed_cmd = { {
        cmd = "rg --files -g '!*__pycache__*'",
        path = vim.NIL,
        type = "list_files"
      } },
    process_id = "82706",
    source = "unified_exec_startup",
    status = "completed",
    stderr = "",
    stdout = "minimal.lua\n",
    turn_id = "019e01d4-3559-73f1-966c-697d5a729713"
  },
  sessionUpdate = "tool_call_update",
  status = "completed",
  toolCallId = "call_lJu6nBoUzDtsLaAVGdbPDSiY"
}
[DEBUG] 2026-05-07 12:45:54
[ACP::Handler] Processing tool call {
  content = { {
      newText = 'def main():\n    print("Hello, world!")\n\n\nif __name__ == "__main__":\n    main()\n',
      path = "/home/chernetskyi/repo/personal/repros/codecompanion-codex-reject/hello.py",
      type = "diff"
    } },
  kind = "edit",
  locations = { {
      path = "/home/chernetskyi/repo/personal/repros/codecompanion-codex-reject/hello.py"
    } },
  rawInput = {
    auto_approved = true,
    call_id = "call_UBRVsyugnnOB9EC7rXsFq9Dw",
    changes = {
      ["/home/chernetskyi/repo/personal/repros/codecompanion-codex-reject/hello.py"] = {
        content = 'def main():\n    print("Hello, world!")\n\n\nif __name__ == "__main__":\n    main()\n',
        type = "add"
      }
    },
    turn_id = "019e01d4-3559-73f1-966c-697d5a729713"
  },
  sessionUpdate = "tool_call",
  status = "in_progress",
  title = "Edit /home/chernetskyi/repo/personal/repros/codecompanion-codex-reject/hello.py",
  toolCallId = "call_UBRVsyugnnOB9EC7rXsFq9Dw"
}
[DEBUG] 2026-05-07 12:45:54
[ACP::Handler] Permission Request
  id: call_UBRVsyugnnOB9EC7rXsFq9Dw
  kind: edit
  Edit /home/chernetskyi/repo/personal/repros/codecompanion-codex-reject/hello.py
  options: { "allow_once", "reject_once" }
[DEBUG] 2026-05-07 12:45:59
[approval_prompt] User selected: View
[DEBUG] 2026-05-07 12:45:59
[acp::request_permission] Opening diff for review
[DEBUG] 2026-05-07 12:46:03
[acp::request_permission] User selected option: reject_once (abort)
[WARN] 2026-05-07 12:46:05
[acp::prompt_builder] Turn ended with stop_reason=cancelled
[INFO] 2026-05-07 12:46:05
Chat request finished

Minimal reproduction confirmation

  • Yes, I have tested and provided a minimal.lua file that reproduces the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreviewed-by-AIThe CodeCompanion agent reviewed this PR

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions