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
4 changes: 3 additions & 1 deletion src/agent_env/agents/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ other with `self.register_secret(value)`, in `run` or later, and the SDK writes
Reference: `enable(TRAJECTORY_V1, live=True, ...)`, `ClaudeCodeAgent.run` passing
`event_callback=request.trajectory.append`, and `get_context_trajectory` / `upload_context_trajectory`. Its adapter,
`claude_code_atif.py`, builds steps from stream-json with each message's time, usage and tools from the CLI's session
transcript, which `claude_bridge.SessionTail` feeds as aux records only while `request.trajectory.builds_atif`. A runtime
transcript, which `claude_bridge.SessionTail` feeds as aux records only while `request.trajectory.builds_atif`. Codex's,
`codex_atif.py`, builds them from the CLI's rollout alone, which `codex_bridge.RolloutTail` feeds; Gemini's,
`gemini_atif.py`, from its session transcript (`gemini_bridge.SessionTail`) and the proxy's call records. A runtime
that only has a record at the end returns it with `native_trajectory(...)`: `agents/pi/pi_agent.py` `_result`.

### `skill-config/v1`, `/ext/skill-config`
Expand Down
2 changes: 1 addition & 1 deletion src/agent_env/agents/agents/codex/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN npm ci --ignore-scripts --omit=dev --no-audit --no-fund --loglevel=error &&
COPY requirements.txt model-requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt -r model-requirements.txt
# install.sh and run.sh are install/v1's: in the image, so they stay in its build context.
COPY a2a_server.py codex_bridge.py codex_config.py codex_kit.py entrypoint.sh install.sh run.sh ./
COPY a2a_server.py codex_atif.py codex_bridge.py codex_config.py codex_kit.py entrypoint.sh install.sh run.sh ./
# The CLI's cwd, /app, and its state, fixed so neither follows the uid: Modal runs the image as root.
RUN useradd --create-home --uid 10001 agent && mkdir -p /app /home/agent/.codex \
&& chown agent:agent /app /home/agent/.codex && chmod 0755 entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion src/agent_env/agents/agents/codex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Codex reads its settings from `$CODEX_HOME/config.toml`, which the agent writes:
| `agent-config/v1` | `CodexConfig`: `model`, `effort` (Codex's `model_reasoning_effort`; a set without it clears it), `system_prompt` (Codex's `developer_instructions`), `output_format` (a JSON schema, as `--output-schema`), `project_id`, `task_id`, `timeout_seconds`, `builtin_tools` (below) |
| `mcp-config/v1` | SDK default; written to `config.toml` before each task |
| `skill-config/v1` | inline and bundle skills installed as `~/.agents/skills/<name>/SKILL.md`, where Codex finds them |
| `trajectory/v1` | the task's `codex exec --json` events, live while it runs (format `codex-exec-json/1`) |
| `trajectory/v1` | the task's `codex exec --json` events, live while it runs (format `codex-exec-json/1`); `atif/1` when the run prescribes it, built live from the CLI's rollout (`codex_atif.py`): a step per model response with its time and usage, each sub-agent embedded under its `spawn_agent` call, a resumed attempt's steps numbered |
| `snapshot/v1` | `save` uploads the thread's rollout JSONL and the workspace as a gzipped tar, each held to a size limit, once no task of the context runs; `load` writes the rollout under a fresh thread id, replaces the workspace's contents (extracted aside first) and binds the thread to the target context |
| `peer-agents/v1` | SDK default: the CLI reaches the task's other agents through the SDK's `peer_agents` MCP tools |
| `attribution-probe/v1` | the `project_id` and `task_id` the last CLI run sent |
Expand Down
13 changes: 12 additions & 1 deletion src/agent_env/agents/agents/codex/a2a_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from starlette.exceptions import HTTPException

import codex_config
from codex_atif import CodexAtif
from codex_bridge import (
SESSIONS_DIR,
CodexResult,
Expand Down Expand Up @@ -232,6 +233,12 @@ def _discard_execution_task(context_id: str, task: asyncio.Task) -> None:
_active_execution_tasks.pop(context_id, None)


def _builds_atif(request: TaskRequest[CodexConfig]) -> bool:
"""Whether the task feeds an atif/1 copy; a protocol from before ``builds_atif`` is taken to, and its copy is built
only when the run prescribed it."""
return getattr(request.trajectory, "builds_atif", True)


class CodexConfig(AgentConfig):
model: str | None = None
effort: str | None = None
Expand Down Expand Up @@ -645,7 +652,10 @@ def total(name: str, of: list[ThreadCalls]) -> int | None:
TRAJECTORY_V1,
live=True,
native=TRAJECTORY_FORMAT,
description="Retrieve a task's Codex --json trajectory, also while it runs.",
atif=CodexAtif,
description=(
"Retrieve a task's Codex --json trajectory, also while it runs; atif/1 when the run prescribes it."
),
),
enable(
ATTRIBUTION_PROBE_V1,
Expand Down Expand Up @@ -749,6 +759,7 @@ def _record_event(event: dict) -> None:
project_id=cfg.project_id,
task_id=cfg.task_id,
event_callback=_record_event,
aux_callback=request.trajectory.aux if _builds_atif(request) else None,
max_turns=cfg.max_turns,
config_overrides=[*codex_config.role_overrides(request.mcp_servers, cfg.role),
*codex_config.builtin_tools_overrides(cfg.builtin_tools),
Expand Down
Loading
Loading