diff --git a/src/agent_env/agents/README.md b/src/agent_env/agents/README.md index 62595d423..f4041d557 100644 --- a/src/agent_env/agents/README.md +++ b/src/agent_env/agents/README.md @@ -21,7 +21,12 @@ the folder changes. A run that deploys the agent registers that image when it's pulls it by its digest and builds it from this folder only when it can't, and a provider that runs images by name can run it. The CLI's version is the Dockerfile's `CLAUDE_CODE_VERSION`. The image gives the scripts the model runs -`node`, without npm or npx, and the Python packages `model-requirements.txt` pins. A `deploy_agent` `builtin_tools` +`node`, without npm or npx, and the Python packages `model-requirements.txt` pins: boto3, and openpyxl, pypdf, +python-docx and python-pptx, which read the .xlsx, .pdf, .docx and .pptx files tasks often give the model. Without them +a script that opens such a file stops at `ModuleNotFoundError`, and the model spends turns working around it or fails +the task for a reason that isn't the model's; a sandbox with no network can't install them either. They add about 50 MB, +mostly the lxml and Pillow they depend on, and their pins match the Codex and Gemini images' and Harbor bundles', so a +task's documents read the same way in each. A `deploy_agent` `builtin_tools` selection picks the CLI's own tools: `{"disable": "*"}` and `{"only": [...]}` become its `--tools` list, a list to turn off becomes `--disallowedTools`, which keeps the CLI's defaults for the rest, and any selection adds `--strict-mcp-config`, so its MCP servers are only the task env's. Tool search is off unless the agent's environment sets diff --git a/src/agent_env/agents/agents/claude-code/model-requirements.txt b/src/agent_env/agents/agents/claude-code/model-requirements.txt index 150d9797f..b04f482f2 100644 --- a/src/agent_env/agents/agents/claude-code/model-requirements.txt +++ b/src/agent_env/agents/agents/claude-code/model-requirements.txt @@ -1,3 +1,8 @@ # What the image gives the Python the model runs, beside the agent's own requirements; an installed agent's model # uses the task container's Python instead. boto3==1.43.115 +# The readers for the .xlsx, .pdf, .docx and .pptx files a task gives the model, at the versions Harbor bundles pin. +openpyxl==3.1.5 +pypdf==6.21.3 +python-docx==1.2.0 +python-pptx==1.0.2 diff --git a/src/agent_env/agents/agents/codex/Dockerfile b/src/agent_env/agents/agents/codex/Dockerfile index 7749f5475..f477158a0 100644 --- a/src/agent_env/agents/agents/codex/Dockerfile +++ b/src/agent_env/agents/agents/codex/Dockerfile @@ -18,8 +18,8 @@ COPY package.json package-lock.json ./ RUN npm ci --ignore-scripts --omit=dev --no-audit --no-fund --loglevel=error && npm cache clean --force \ && ln -s /opt/agent/node_modules/.bin/codex /usr/local/bin/codex \ && ln -s /opt/agent/node_modules/.bin/mcp-remote /usr/local/bin/mcp-remote -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +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 ./ # The CLI's cwd, /app, and its state, fixed so neither follows the uid: Modal runs the image as root. diff --git a/src/agent_env/agents/agents/codex/README.md b/src/agent_env/agents/agents/codex/README.md index 118cc8806..ace3dad2c 100644 --- a/src/agent_env/agents/agents/codex/README.md +++ b/src/agent_env/agents/agents/codex/README.md @@ -36,7 +36,8 @@ Codex reads its settings from `$CODEX_HOME/config.toml`, which the agent writes: | `install/v1` | `install.sh`, into a task container (as root, the CLI working in `/app`) or onto a `vm` sandbox's Linux host: Node and uv checked against their checksums, the CLIs from `package-lock.json` and the agent's requirements in a Python of its own, which the target's own Node and Python are never replaced by; the model's commands get the agent's where the target has none. Node's builds need glibc | | `triggers/v1` | SDK default | -The image is `python:3.11-slim` with Node, the CLIs and the agent, running as the `agent` user; Codex's state is in +The image is `python:3.11-slim` with Node, the CLIs, the agent and the Python packages `model-requirements.txt` pins for +the model's scripts, running as the `agent` user; Codex's state is in `/home/agent/.codex` whatever the uid. A `deploy_agent` `builtin_tools` selection turns the CLI's own tools off with `-c` overrides on the task's CLI alone; diff --git a/src/agent_env/agents/agents/codex/model-requirements.txt b/src/agent_env/agents/agents/codex/model-requirements.txt new file mode 100644 index 000000000..fd0f8c861 --- /dev/null +++ b/src/agent_env/agents/agents/codex/model-requirements.txt @@ -0,0 +1,7 @@ +# What the image gives the Python the model runs, beside the agent's own requirements; an installed agent's model +# uses the task container's Python instead. +# The readers for the .xlsx, .pdf, .docx and .pptx files a task gives the model, at the versions Harbor bundles pin. +openpyxl==3.1.5 +pypdf==6.21.3 +python-docx==1.2.0 +python-pptx==1.0.2 diff --git a/src/agent_env/agents/agents/gemini/Dockerfile b/src/agent_env/agents/agents/gemini/Dockerfile index c1d6c0acd..c2f7159ef 100644 --- a/src/agent_env/agents/agents/gemini/Dockerfile +++ b/src/agent_env/agents/agents/gemini/Dockerfile @@ -17,8 +17,8 @@ WORKDIR /opt/agent COPY package.json package-lock.json ./ RUN npm ci --ignore-scripts --omit=dev --no-audit --no-fund --loglevel=error && npm cache clean --force \ && ln -s /opt/agent/node_modules/.bin/gemini /usr/local/bin/gemini -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +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 gemini_bridge.py gemini_changelog.py gemini_config.py gemini_kit.py entrypoint.sh install.sh run.sh ./ # The CLI's cwd and file-tool boundary, /workspace, and its state, fixed so neither follows the uid: Modal runs the diff --git a/src/agent_env/agents/agents/gemini/README.md b/src/agent_env/agents/agents/gemini/README.md index 0852c2649..c455edc07 100644 --- a/src/agent_env/agents/agents/gemini/README.md +++ b/src/agent_env/agents/agents/gemini/README.md @@ -38,5 +38,6 @@ CLI by its last segment, and the proxy translates its generate calls to `/v1/cha | `install/v1` | `install.sh`, into a task container (as root, the CLI working in `/workspace`) or onto a `vm` sandbox's Linux host: Node and uv checked against their checksums, the CLI from `package-lock.json` and the agent's requirements in a Python of its own, which the target's own Node and Python are never replaced by; the model's commands get the agent's where the target has none. Node's builds need glibc | | `triggers/v1` | SDK default | -The image is `python:3.11-slim` with Node, the CLI and the agent, running as the `agent` user; the CLI's state is in +The image is `python:3.11-slim` with Node, the CLI, the agent and the Python packages `model-requirements.txt` pins for +the model's scripts, running as the `agent` user; the CLI's state is in `/home/agent/.gemini` (`GEMINI_CLI_HOME`) whatever the uid. diff --git a/src/agent_env/agents/agents/gemini/model-requirements.txt b/src/agent_env/agents/agents/gemini/model-requirements.txt new file mode 100644 index 000000000..fd0f8c861 --- /dev/null +++ b/src/agent_env/agents/agents/gemini/model-requirements.txt @@ -0,0 +1,7 @@ +# What the image gives the Python the model runs, beside the agent's own requirements; an installed agent's model +# uses the task container's Python instead. +# The readers for the .xlsx, .pdf, .docx and .pptx files a task gives the model, at the versions Harbor bundles pin. +openpyxl==3.1.5 +pypdf==6.21.3 +python-docx==1.2.0 +python-pptx==1.0.2 diff --git a/tst/unit/agents/claude_code/test_image_contract.py b/tst/unit/agents/claude_code/test_image_contract.py index 6445b09d6..c8e528df3 100644 --- a/tst/unit/agents/claude_code/test_image_contract.py +++ b/tst/unit/agents/claude_code/test_image_contract.py @@ -9,6 +9,9 @@ DOCKERFILE = (AGENT_DIR / "Dockerfile").read_text() +# Harbor bundles pin the same versions (agentenvhub-sdk's _DOC_TOOL_PACKAGES), so a task's documents read alike in both. +DOC_LIBS = ["openpyxl==3.1.5", "pypdf==6.21.3", "python-docx==1.2.0", "python-pptx==1.0.2"] + def test_every_file_the_image_copies_is_in_the_folder(): copied = [name for line in re.findall(r"^COPY (?!--from=)(.+) \S+$", DOCKERFILE, re.MULTILINE) @@ -39,6 +42,7 @@ def test_the_packages_the_image_gives_the_models_python_are_pinned(): assert packages and all(re.fullmatch(r"[A-Za-z0-9_.-]+==[0-9][0-9A-Za-z.]*", line) for line in packages), packages assert any(line.startswith("boto3==") for line in packages) + assert set(DOC_LIBS) <= set(packages), packages assert "-r requirements.txt -r model-requirements.txt" in DOCKERFILE diff --git a/tst/unit/agents/codex/test_image_contract.py b/tst/unit/agents/codex/test_image_contract.py index dfc7fc6ba..eec0cd5d3 100644 --- a/tst/unit/agents/codex/test_image_contract.py +++ b/tst/unit/agents/codex/test_image_contract.py @@ -14,6 +14,10 @@ INSTALL_SH = (AGENT_DIR / "install.sh").read_text() +# Harbor bundles pin the same versions (agentenvhub-sdk's _DOC_TOOL_PACKAGES), so a task's documents read alike in both. +DOC_LIBS = ["openpyxl==3.1.5", "pypdf==6.21.3", "python-docx==1.2.0", "python-pptx==1.0.2"] + + def _copied() -> list[str]: return [name for line in re.findall(r"^COPY (?!--from=)(.+) \S+$", DOCKERFILE, re.MULTILINE) for name in line.split()] @@ -53,6 +57,15 @@ def test_the_requirements_are_the_protocol_floor_the_config_writer_and_the_ca_bu assert requirements == ["agentenv-framework-protocol[agent]>=0.1.351", "tomli-w==1.2.0", "certifi"] +def test_the_image_gives_the_models_python_the_document_libraries(): + packages = [line for line in (AGENT_DIR / "model-requirements.txt").read_text().splitlines() + if line and not line.startswith("#")] + + assert packages == DOC_LIBS + assert "COPY requirements.txt model-requirements.txt ./" in DOCKERFILE + assert "RUN pip install --no-cache-dir -r requirements.txt -r model-requirements.txt" in DOCKERFILE + + def test_node_is_pinned_by_version_and_checksum_for_the_image_and_an_install(): args = dict(re.findall(r"^ARG (NODE_\w+)=(\S+)$", DOCKERFILE, re.MULTILINE)) diff --git a/tst/unit/agents/gemini/test_image_contract.py b/tst/unit/agents/gemini/test_image_contract.py index 1f783a056..a982e3620 100644 --- a/tst/unit/agents/gemini/test_image_contract.py +++ b/tst/unit/agents/gemini/test_image_contract.py @@ -14,6 +14,10 @@ INSTALL_SH = (AGENT_DIR / "install.sh").read_text() +# Harbor bundles pin the same versions (agentenvhub-sdk's _DOC_TOOL_PACKAGES), so a task's documents read alike in both. +DOC_LIBS = ["openpyxl==3.1.5", "pypdf==6.21.3", "python-docx==1.2.0", "python-pptx==1.0.2"] + + def _copied() -> list[str]: return [name for line in re.findall(r"^COPY (?!--from=)(.+) \S+$", DOCKERFILE, re.MULTILINE) for name in line.split()] @@ -53,6 +57,15 @@ def test_the_image_installs_the_protocol_alone_from_its_requirements(): assert requirements == ["agentenv-framework-protocol[agent]>=0.1.351"] +def test_the_image_gives_the_models_python_the_document_libraries(): + packages = [line for line in (AGENT_DIR / "model-requirements.txt").read_text().splitlines() + if line and not line.startswith("#")] + + assert packages == DOC_LIBS + assert "COPY requirements.txt model-requirements.txt ./" in DOCKERFILE + assert "RUN pip install --no-cache-dir -r requirements.txt -r model-requirements.txt" in DOCKERFILE + + def test_node_is_pinned_by_version_and_checksum_for_the_image_and_an_install(): args = dict(re.findall(r"^ARG (NODE_\w+)=(\S+)$", DOCKERFILE, re.MULTILINE))