Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions environments/SWE-INFINITE/agents/codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from utils import SANITIZE_GIT_SCRIPT, NORMALIZE_TIMESTAMPS_SCRIPT, NETWORK_BLOCKLIST_SCRIPT, DIFF_EXTENSIONS

DOCKER_PULL_TIMEOUT = 300
SHELL_EDIT_INSTRUCTIONS = Path(__file__).with_name("codex_system_prompt_shell_edits.txt")

# Pre-built static codex binary — search common locations.
def _find_codex_binary() -> str:
Expand Down Expand Up @@ -93,9 +94,16 @@ def _install_codex(self) -> bool:
def _write_codex_config(self) -> None:
"""Write codex config.toml inside the container (wire_api=chat for OpenAI-compatible endpoints)."""
base_url = self.config.api_base
instructions = SHELL_EDIT_INSTRUCTIONS.read_text()
self._exec(
"mkdir -p /root/.codex && cat > /root/.codex/model_instructions.md",
timeout=10,
stdin_data=instructions,
)
config_toml = (
f'model = {json.dumps(self.config.model)}\n'
f'model_provider = "chutes"\n'
f'model_instructions_file = "/root/.codex/model_instructions.md"\n'
f'\n'
f'[model_providers.chutes]\n'
f'name = "Chutes"\n'
Expand Down Expand Up @@ -195,6 +203,13 @@ def _build_prompt(
lines.append("- Modify ONLY source code files under /app. Do NOT modify tests or config files.")
lines.append("- Read relevant source files to understand the codebase before making changes.")
lines.append("- Make minimal, focused changes that directly address the issue.")
lines.append("")
lines.append("## Tool Contract")
lines.append("")
lines.append("- Do not emit XML, JSON, or pseudo tool calls in assistant text.")
lines.append("- To edit files, call the available `shell` tool and run commands that actually modify files under /app.")
lines.append("- Recommended edit methods include `sed -i`, `perl -0pi`, small Python rewrite scripts, `cat > file`, or `git apply` from a unified diff file.")
lines.append("- The evaluator scores the real working tree diff; assistant text describing an edit is not applied.")

return "\n".join(lines)

Expand Down
Loading