[PR #14122] [MERGED] cmd: set codex env vars on launch and handle zstd request bodies #40398

Closed
opened 2026-04-23 01:17:57 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14122
Author: @BruceMacD
Created: 2/6/2026
Status: Merged
Merged: 2/19/2026
Merged by: @BruceMacD

Base: mainHead: brucemacd/pass-launch-args


📝 Commits (1)

  • c487481 cmd: set codex env vars on launch and handle zstd request bodies

📊 Changes

5 files changed (+120 additions, -2 deletions)

View changed files

📝 cmd/config/codex.go (+5 -0)
📝 go.mod (+1 -0)
📝 go.sum (+2 -2)
📝 middleware/openai.go (+12 -0)
📝 middleware/openai_test.go (+100 -0)

📄 Description

The Codex runner was not setting OPENAI_BASE_URL or OPENAI_API_KEY, this prevents Codex from sending requests to api.openai.com instead of the local Ollama server. This mirrors the approach used by the Claude runner.

Codex v0.98.0 sends zstd-compressed request bodies to the /v1/responses endpoint in some cases. Add decompression support in ResponsesMiddleware with an 8MB max decompressed size limit to prevent resource exhaustion.

Before:

❯ ollama launch codex -- exec 'hi'
...
user
hi
2026-02-06T18:11:29.919587Z ERROR codex_api::endpoint::responses: error=http 401 Unauthorized: Some("{\n  \"error\": {\n    \"message\": \"Missing bearer or basic authentication in header\",\n    \"type\": \"invalid_request_error\",\n    \"param\": null,\n    \"code\": null\n  }\n}")

After:

❯ ./ollama launch codex -- exec 'hi'

Launching Codex with glm-4.7:cloud...
...
user
hi
mcp startup: no servers
thinking
...
codex
Hi! I'm here to help. What would you like to work on today?
tokens used
7,079
Hi! I'm here to help. What would you like to work on today?

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14122 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 2/6/2026 **Status:** ✅ Merged **Merged:** 2/19/2026 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/pass-launch-args` --- ### 📝 Commits (1) - [`c487481`](https://github.com/ollama/ollama/commit/c487481a31cb22a08d91a6cab9be398b761389e3) cmd: set codex env vars on launch and handle zstd request bodies ### 📊 Changes **5 files changed** (+120 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `cmd/config/codex.go` (+5 -0) 📝 `go.mod` (+1 -0) 📝 `go.sum` (+2 -2) 📝 `middleware/openai.go` (+12 -0) 📝 `middleware/openai_test.go` (+100 -0) </details> ### 📄 Description The Codex runner was not setting OPENAI_BASE_URL or OPENAI_API_KEY, this prevents Codex from sending requests to api.openai.com instead of the local Ollama server. This mirrors the approach used by the Claude runner. Codex v0.98.0 sends zstd-compressed request bodies to the /v1/responses endpoint in some cases. Add decompression support in ResponsesMiddleware with an 8MB max decompressed size limit to prevent resource exhaustion. Before: ```bash ❯ ollama launch codex -- exec 'hi' ... user hi 2026-02-06T18:11:29.919587Z ERROR codex_api::endpoint::responses: error=http 401 Unauthorized: Some("{\n \"error\": {\n \"message\": \"Missing bearer or basic authentication in header\",\n \"type\": \"invalid_request_error\",\n \"param\": null,\n \"code\": null\n }\n}") ``` After: ```bash ❯ ./ollama launch codex -- exec 'hi' Launching Codex with glm-4.7:cloud... ... user hi mcp startup: no servers thinking ... codex Hi! I'm here to help. What would you like to work on today? tokens used 7,079 Hi! I'm here to help. What would you like to work on today? ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 01:17:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#40398