Skip to content

Commit f5c9054

Browse files
fix: codex no change bug
1 parent 8b94670 commit f5c9054

File tree

2 files changed

+98
-66
lines changed

2 files changed

+98
-66
lines changed

server/utils/code_task_v1.py

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _run_ai_code_task_internal(task_id):
154154
echo "CODEX_QUIET_MODE: $CODEX_QUIET_MODE"
155155
echo "CODEX_UNSAFE_ALLOW_NO_SANDBOX: $CODEX_UNSAFE_ALLOW_NO_SANDBOX"
156156
echo "OPENAI_API_KEY: $(echo $OPENAI_API_KEY | head -c 8)..."
157-
echo "USING DOCKER-OPTIMIZED FLAGS: --dangerously-auto-approve-everything without --approval-mode full-auto"
157+
echo "USING OFFICIAL CODEX FLAGS: --approval-mode full-auto --quiet for non-interactive operation"
158158
echo "======================="
159159
160160
# Read the prompt from file
@@ -165,10 +165,10 @@ def _run_ai_code_task_internal(task_id):
165165
echo "Found codex at /usr/local/bin/codex"
166166
echo "Running Codex in non-interactive mode..."
167167
168-
# Use non-interactive flags for Docker environment
169-
# Using only --dangerously-auto-approve-everything as recommended by Codex error message
170-
# Avoiding --approval-mode full-auto which triggers problematic sandboxing in Docker
171-
/usr/local/bin/codex --dangerously-auto-approve-everything --quiet "$PROMPT_TEXT"
168+
# Use official non-interactive flags for Docker environment
169+
# Using --approval-mode full-auto as per official Codex documentation
170+
# Also disable Codex's internal sandboxing to prevent conflicts with Docker
171+
/usr/local/bin/codex --approval-mode full-auto --quiet "$PROMPT_TEXT"
172172
CODEX_EXIT_CODE=$?
173173
echo "Codex finished with exit code: $CODEX_EXIT_CODE"
174174
@@ -182,10 +182,10 @@ def _run_ai_code_task_internal(task_id):
182182
echo "Using codex from PATH..."
183183
echo "Running Codex in non-interactive mode..."
184184
185-
# Use non-interactive flags for Docker environment
186-
# Using only --dangerously-auto-approve-everything as recommended by Codex error message
187-
# Avoiding --approval-mode full-auto which triggers problematic sandboxing in Docker
188-
codex --dangerously-auto-approve-everything --quiet "$PROMPT_TEXT"
185+
# Use official non-interactive flags for Docker environment
186+
# Using --approval-mode full-auto as per official Codex documentation
187+
# Also disable Codex's internal sandboxing to prevent conflicts with Docker
188+
codex --approval-mode full-auto --quiet "$PROMPT_TEXT"
189189
CODEX_EXIT_CODE=$?
190190
echo "Codex finished with exit code: $CODEX_EXIT_CODE"
191191
@@ -314,34 +314,50 @@ def _run_ai_code_task_internal(task_id):
314314
315315
# Check if there are changes
316316
if git diff --quiet; then
317-
echo "No changes made"
318-
exit 1
319-
fi
320-
321-
# Commit changes locally
322-
git add .
323-
git commit -m "{model_cli.capitalize()}: {escaped_prompt[:100]}"
317+
echo "ℹ️ No changes made by {model_cli.upper()} - this is a valid outcome"
318+
echo "The AI tool ran successfully but decided not to make changes"
319+
320+
# Create empty patch and diff for consistency
321+
echo "=== PATCH START ==="
322+
echo "No changes were made"
323+
echo "=== PATCH END ==="
324+
325+
echo "=== GIT DIFF START ==="
326+
echo "No changes were made"
327+
echo "=== GIT DIFF END ==="
328+
329+
echo "=== CHANGED FILES START ==="
330+
echo "No files were changed"
331+
echo "=== CHANGED FILES END ==="
332+
333+
# Set empty commit hash
334+
echo "COMMIT_HASH="
335+
else
336+
# Commit changes locally
337+
git add .
338+
git commit -m "{model_cli.capitalize()}: {escaped_prompt[:100]}"
324339
325-
# Get commit info
326-
COMMIT_HASH=$(git rev-parse HEAD)
327-
echo "COMMIT_HASH=$COMMIT_HASH"
340+
# Get commit info
341+
COMMIT_HASH=$(git rev-parse HEAD)
342+
echo "COMMIT_HASH=$COMMIT_HASH"
328343
329-
# Generate patch file for later application
330-
echo "📦 Generating patch file..."
331-
git format-patch HEAD~1 --stdout > /tmp/changes.patch
332-
echo "=== PATCH START ==="
333-
cat /tmp/changes.patch
334-
echo "=== PATCH END ==="
344+
# Generate patch file for later application
345+
echo "📦 Generating patch file..."
346+
git format-patch HEAD~1 --stdout > /tmp/changes.patch
347+
echo "=== PATCH START ==="
348+
cat /tmp/changes.patch
349+
echo "=== PATCH END ==="
335350
336-
# Also get the diff for display
337-
echo "=== GIT DIFF START ==="
338-
git diff HEAD~1 HEAD
339-
echo "=== GIT DIFF END ==="
351+
# Also get the diff for display
352+
echo "=== GIT DIFF START ==="
353+
git diff HEAD~1 HEAD
354+
echo "=== GIT DIFF END ==="
340355
341-
# List changed files for reference
342-
echo "=== CHANGED FILES START ==="
343-
git diff --name-only HEAD~1 HEAD
344-
echo "=== CHANGED FILES END ==="
356+
# List changed files for reference
357+
echo "=== CHANGED FILES START ==="
358+
git diff --name-only HEAD~1 HEAD
359+
echo "=== CHANGED FILES END ==="
360+
fi
345361
346362
# Explicitly exit with success code
347363
echo "Container work completed successfully"

server/utils/code_task_v2.py

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _run_ai_code_task_v2_internal(task_id: int, user_id: str, github_token: str)
221221
echo "CODEX_QUIET_MODE: $CODEX_QUIET_MODE"
222222
echo "CODEX_UNSAFE_ALLOW_NO_SANDBOX: $CODEX_UNSAFE_ALLOW_NO_SANDBOX"
223223
echo "OPENAI_API_KEY: $(echo $OPENAI_API_KEY | head -c 8)..."
224-
echo "USING DOCKER-OPTIMIZED FLAGS: --dangerously-auto-approve-everything without --approval-mode full-auto"
224+
echo "USING OFFICIAL CODEX FLAGS: --approval-mode full-auto --quiet for non-interactive operation"
225225
echo "======================="
226226
227227
# Read the prompt from file
@@ -232,10 +232,10 @@ def _run_ai_code_task_v2_internal(task_id: int, user_id: str, github_token: str)
232232
echo "Found codex at /usr/local/bin/codex"
233233
echo "Running Codex in non-interactive mode..."
234234
235-
# Use non-interactive flags for Docker environment
236-
# Using only --dangerously-auto-approve-everything as recommended by Codex error message
237-
# Avoiding --approval-mode full-auto which triggers problematic sandboxing in Docker
238-
/usr/local/bin/codex --dangerously-auto-approve-everything --quiet "$PROMPT_TEXT"
235+
# Use official non-interactive flags for Docker environment
236+
# Using --approval-mode full-auto as per official Codex documentation
237+
# Also disable Codex's internal sandboxing to prevent conflicts with Docker
238+
/usr/local/bin/codex --approval-mode full-auto --quiet "$PROMPT_TEXT"
239239
CODEX_EXIT_CODE=$?
240240
echo "Codex finished with exit code: $CODEX_EXIT_CODE"
241241
@@ -249,10 +249,10 @@ def _run_ai_code_task_v2_internal(task_id: int, user_id: str, github_token: str)
249249
echo "Using codex from PATH..."
250250
echo "Running Codex in non-interactive mode..."
251251
252-
# Use non-interactive flags for Docker environment
253-
# Using only --dangerously-auto-approve-everything as recommended by Codex error message
254-
# Avoiding --approval-mode full-auto which triggers problematic sandboxing in Docker
255-
codex --dangerously-auto-approve-everything --quiet "$PROMPT_TEXT"
252+
# Use official non-interactive flags for Docker environment
253+
# Using --approval-mode full-auto as per official Codex documentation
254+
# Also disable Codex's internal sandboxing to prevent conflicts with Docker
255+
codex --approval-mode full-auto --quiet "$PROMPT_TEXT"
256256
CODEX_EXIT_CODE=$?
257257
echo "Codex finished with exit code: $CODEX_EXIT_CODE"
258258
@@ -381,34 +381,50 @@ def _run_ai_code_task_v2_internal(task_id: int, user_id: str, github_token: str)
381381
382382
# Check if there are changes
383383
if git diff --quiet; then
384-
echo "No changes made"
385-
exit 1
386-
fi
387-
388-
# Commit changes locally
389-
git add .
390-
git commit -m "{model_cli.capitalize()}: {escaped_prompt[:100]}"
384+
echo "ℹ️ No changes made by {model_cli.upper()} - this is a valid outcome"
385+
echo "The AI tool ran successfully but decided not to make changes"
386+
387+
# Create empty patch and diff for consistency
388+
echo "=== PATCH START ==="
389+
echo "No changes were made"
390+
echo "=== PATCH END ==="
391+
392+
echo "=== GIT DIFF START ==="
393+
echo "No changes were made"
394+
echo "=== GIT DIFF END ==="
395+
396+
echo "=== CHANGED FILES START ==="
397+
echo "No files were changed"
398+
echo "=== CHANGED FILES END ==="
399+
400+
# Set empty commit hash
401+
echo "COMMIT_HASH="
402+
else
403+
# Commit changes locally
404+
git add .
405+
git commit -m "{model_cli.capitalize()}: {escaped_prompt[:100]}"
391406
392-
# Get commit info
393-
COMMIT_HASH=$(git rev-parse HEAD)
394-
echo "COMMIT_HASH=$COMMIT_HASH"
407+
# Get commit info
408+
COMMIT_HASH=$(git rev-parse HEAD)
409+
echo "COMMIT_HASH=$COMMIT_HASH"
395410
396-
# Generate patch file for later application
397-
echo "📦 Generating patch file..."
398-
git format-patch HEAD~1 --stdout > /tmp/changes.patch
399-
echo "=== PATCH START ==="
400-
cat /tmp/changes.patch
401-
echo "=== PATCH END ==="
411+
# Generate patch file for later application
412+
echo "📦 Generating patch file..."
413+
git format-patch HEAD~1 --stdout > /tmp/changes.patch
414+
echo "=== PATCH START ==="
415+
cat /tmp/changes.patch
416+
echo "=== PATCH END ==="
402417
403-
# Also get the diff for display
404-
echo "=== GIT DIFF START ==="
405-
git diff HEAD~1 HEAD
406-
echo "=== GIT DIFF END ==="
418+
# Also get the diff for display
419+
echo "=== GIT DIFF START ==="
420+
git diff HEAD~1 HEAD
421+
echo "=== GIT DIFF END ==="
407422
408-
# List changed files for reference
409-
echo "=== CHANGED FILES START ==="
410-
git diff --name-only HEAD~1 HEAD
411-
echo "=== CHANGED FILES END ==="
423+
# List changed files for reference
424+
echo "=== CHANGED FILES START ==="
425+
git diff --name-only HEAD~1 HEAD
426+
echo "=== CHANGED FILES END ==="
427+
fi
412428
413429
# Explicitly exit with success code
414430
echo "Container work completed successfully"

0 commit comments

Comments
 (0)